gempendencies 0.1.0

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
+ SHA256:
3
+ metadata.gz: 174a5a541ad86cef48f122d348dfdb0725cecc3ebc2e182a9511026defc987f2
4
+ data.tar.gz: d7c0f0e717c1946faa828a4e84fdf1bec528d083429615c7978e68f0aaed6452
5
+ SHA512:
6
+ metadata.gz: dabde61dcec1d84b1d8a52f8a73cab1de161dcaf3058da51e9a75a9b392fc717210a092b0af956dac6b7cc20b8022f4136a85425f409ed975d670bad76f569ac
7
+ data.tar.gz: 6518bad7caf4df392585a53fd6e35bf5d34b9c9ae4e2cf72344bd5c4bd7d9547eb8adcefcdb343ca8f7ffe6486031a7772ab308bdc109ca9f41f220cff9ec26a
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ .gempendencies
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gempendencies.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gempendencies (0.1.0)
5
+ nokogiri
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.4.4)
11
+ mini_portile2 (2.5.0)
12
+ nokogiri (1.11.2)
13
+ mini_portile2 (~> 2.5.0)
14
+ racc (~> 1.4)
15
+ racc (1.5.2)
16
+ rake (10.5.0)
17
+ rspec (3.10.0)
18
+ rspec-core (~> 3.10.0)
19
+ rspec-expectations (~> 3.10.0)
20
+ rspec-mocks (~> 3.10.0)
21
+ rspec-core (3.10.1)
22
+ rspec-support (~> 3.10.0)
23
+ rspec-expectations (3.10.1)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.10.0)
26
+ rspec-mocks (3.10.2)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.10.0)
29
+ rspec-support (3.10.2)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ bundler (~> 2.0)
36
+ gempendencies!
37
+ rake (~> 10.0)
38
+ rspec (~> 3.0)
39
+
40
+ BUNDLED WITH
41
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 dhicks@verisys.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Gempendencies
2
+ Builds a comprehensive list of gems used by your project
3
+
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gempendencies'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gempendencies
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gempendencies.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gempendencies"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/gempendencies ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ unless File.exist?('./Rakefile') || File.exist?('./Gemfile')
4
+ abort 'Please run gempendencies from the root of the project.'
5
+ end
6
+
7
+ require 'rubygems'
8
+ begin
9
+ require 'bundler'
10
+ Bundler.setup
11
+ rescue StandardError => e
12
+ puts "ERROR: #{e.message}"
13
+ end
14
+
15
+ here = File.expand_path(File.dirname __FILE__)
16
+ $LOAD_PATH << "#{here}/../lib"
17
+
18
+ require 'gempendencies'
19
+ require 'gempendencies/gem_info'
20
+
21
+ Gempendencies::GemInfo.new.build
@@ -0,0 +1,27 @@
1
+ # Build an informative list of all Gems used by the project - this will take a minute to run
2
+ mkdir -p .gempendencies
3
+
4
+ echo "Calling 'gem info' for every gem in the project...patience is a virtue..."
5
+ for gem in `bundle list | sed 's/ \* \(.*\) (.*/\1/g' | grep -v " "`
6
+ do echo "------------------------ $gem -----------------------------------"
7
+ gem info $gem | grep -v "Installed at"
8
+ done | tee .gempendencies/gem_info.txt
9
+
10
+ echo "Building License Counts"
11
+ echo "#---#---#---#---#---#---#---#---#---#---#---#---#---#---#" | tee -a .gempendencies/gem_info.txt
12
+ echo " Licenses " | tee -a .gempendencies/gem_info.txt
13
+ echo "#---#---#---#---#---#---#---#---#---#---#---#---#---#---#" | tee -a .gempendencies/gem_info.txt
14
+ grep "License[s]*" .gempendencies/gem_info.txt | sed 's/.*License[s]*: \(.*\)/\1/g' | sort | uniq -c | sort -n -r | tee -a .gempendencies/gem_info.txt
15
+
16
+ echo "Building Prolific Author Counts"
17
+ echo "#---#---#---#---#---#---#---#---#---#---#---#---#---#---#" | tee -a .gempendencies/gem_info.txt
18
+ echo " Top Gem Authors " | tee -a .gempendencies/gem_info.txt
19
+ echo "#---#---#---#---#---#---#---#---#---#---#---#---#---#---#" | tee -a .gempendencies/gem_info.txt
20
+ grep "Author[s]*:" .gempendencies/gem_info.txt | sed 's/.*Author[s]*: \(.*\)/\1/g' | sort | uniq -c | sort -n -r | head -n 15 | tee -a .gempendencies/gem_info.txt
21
+
22
+ echo "#---#---#---#---#---#---#---#---#---#---#---#---#---#---#" | tee -a .gempendencies/gem_info.txt
23
+ echo " Total Gem Count " | tee -a .gempendencies/gem_info.txt
24
+ echo "#---#---#---#---#---#---#---#---#---#---#---#---#---#---#" | tee -a .gempendencies/gem_info.txt
25
+ grep "Author[s]*:" .gempendencies/gem_info.txt | wc -l | tee -a .gempendencies/gem_info.txt
26
+
27
+ echo "We done - check out gem_info.txt for results"
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "gempendencies/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "gempendencies"
7
+ spec.version = Gempendencies::VERSION
8
+ spec.authors = ["Darren Hicks"]
9
+ spec.email = ["darren.hicks@gmail.com"]
10
+
11
+ spec.summary = %q{Builds a comprehensive list of gems used by your project}
12
+ spec.description = %q{Builds a comprehensive list of gems used by your project}
13
+ spec.homepage = "https://github.com/deevis/gempendencies"
14
+ spec.license = "MIT"
15
+
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/deevis/gempendencies"
19
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "nokogiri"
31
+
32
+ spec.add_development_dependency "bundler", "~> 2.0"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ end
@@ -0,0 +1,6 @@
1
+ require "gempendencies/version"
2
+
3
+ module Gempendencies
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,157 @@
1
+ require 'gempendencies'
2
+ require 'json'
3
+ require 'nokogiri'
4
+ require 'open-uri'
5
+ require 'set'
6
+ require 'securerandom'
7
+
8
+ module Gempendencies
9
+
10
+ # Build gem_info.txt
11
+
12
+ # Cool things to build off of...
13
+ #
14
+ # forked repos:
15
+ # for file in `find gem_info -iname "curl_result.json"`; do grep -H 'fork":' $file; done | grep true
16
+ #
17
+ # archived repos:
18
+ # for file in `find gem_info -iname "curl_result.json"`; do grep -H 'archived":' $file; done | grep true
19
+ #
20
+ # most starred:
21
+ # for file in `find gem_info -iname "curl_result.json"`; do grep -H 'watchers":' $file; done | sed 's/gem_info\/\(.*\).*\/.*ers": \([0-9]*\),/\2 \1/g' | sort -n -r | head -n 20
22
+ #
23
+ # least starred:
24
+ # file in `find gem_info -iname "curl_result.json"`; do grep -H 'watchers":' $file; done | sed 's/gem_info\/\(.*\).*\/.*ers": \([0-9]*\),/\2 \1/g' | sort -n | head -n 20
25
+ #
26
+ # most issues:
27
+ # for file in `find gem_info -iname "curl_result.json"`; do grep -H 'issues":' $file; done | sed 's/gem_info\/\(.*\).*\/.*sues": \([0-9]*\),/\2 \1/g' | sort -n -r | head -n 20
28
+ #
29
+ #
30
+ # all svg files scraped and summarized:
31
+ # find gem_info -name "*.svg" | sed 's/..*\/.*\/.*\/\(.*\)/\1/g' | sort | uniq -c | sort -n
32
+ #
33
+
34
+ class GemInfo
35
+ def initialize
36
+ @domain_badge_labels = {}
37
+ # note - be sure to double backslash all the CLI backslashes
38
+ if File.exist?(".gempendencies/gem_info.txt")
39
+ github_urls
40
+ else
41
+ "You need to generate gem_info.txt - GemInfo.new.build_gem_info_txt"
42
+ end
43
+ end
44
+
45
+ # uses bundler to build the gem_info.txt summarization of all gems used...
46
+ def build_gem_info_txt
47
+ # https://gist.github.com/deevis/3211023e2b14e85df6ca908dbc642a2d
48
+ # https://gist.githubusercontent.com/deevis/3211023e2b14e85df6ca908dbc642a2d/raw/9fe1c9dfedc15b328cbe2e3f64f8198d56bb9795/generate_gem_info.sh
49
+ `bin/generate_gem_info.sh`
50
+ end
51
+
52
+ def github_urls
53
+ @github_urls = `grep "Homepage:" .gempendencies/gem_info.txt | grep "github" | sed 's/.*page: \\(.*\\)/\\1/g'`.split("\n").uniq
54
+ #puts @github_urls
55
+ puts "Got #{@github_urls.length} github urls to process"
56
+ @github_urls
57
+ end
58
+
59
+ def get_badges(url, directory)
60
+ `rm #{directory}/unknown*.svg`
61
+ # `rm #{directory}/*.svg`
62
+ begin
63
+ doc = Nokogiri::HTML(URI.open(url))
64
+ rescue => e
65
+ puts "Error[#{url}] : #{e.message}"
66
+ return
67
+ end
68
+ articles = doc.css("#readme article")
69
+ images = articles.css("a img")
70
+
71
+ images.each do |i|
72
+ canonical_source = i['data-canonical-src']
73
+ image_url = i['src']
74
+ label = i["alt"]&.gsub(' ','_')&.downcase
75
+ if canonical_source.nil? || canonical_source.index("yard-docs")
76
+ puts "Skipping: #{canonical_source || label}"
77
+ next
78
+ end
79
+ extension = canonical_source.split("?").first.scan(/\....$/).first || '.svg'
80
+ puts " canonical_source: #{canonical_source}"
81
+ puts " image_url: #{image_url}"
82
+ puts " label: #{label}"
83
+ domain = canonical_source.scan(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/).flatten[0]
84
+ if label
85
+ (@domain_badge_labels[domain] ||= Set.new) << label
86
+ else
87
+ labels = @domain_badge_labels[domain]
88
+ if labels.nil?
89
+ puts " ERROR - no known labels for #{domain}"
90
+ label = "unknown_#{SecureRandom.hex(3)}"
91
+ elsif labels.length > 1
92
+ puts " ERROR - multiple possible labels for #{domain} - #{labels}"
93
+ label = "unknown_#{SecureRandom.hex(3)}"
94
+ else
95
+ label = labels.to_a[0]
96
+ puts " derived label: #{label}"
97
+ end
98
+ end
99
+ image_name = "#{label}#{extension}"
100
+ next if File.exist?("#{directory}/#{image_name}")
101
+ # curl: -L follow redirects
102
+ cmd = "curl -L #{canonical_source} -o #{directory}/#{image_name}"
103
+ puts cmd
104
+ `#{cmd}`
105
+ end
106
+ end
107
+
108
+ def get_repo_json(url, file)
109
+ cmd = "curl #{url} > #{file}"
110
+ puts cmd
111
+ `#{cmd}`
112
+ if (contents = File.read(file)).index("rate limit exceeded")
113
+ puts "Exceeded rate limit (#{url})"
114
+ raise contents
115
+ elsif contents.index("Moved Permanently")
116
+ url = JSON.parse(contents)['url']
117
+ puts "Moved Permanently to: #{url}"
118
+ contents = get_repo_json(url, file)
119
+ end
120
+ sleep 0.5
121
+ contents
122
+ end
123
+
124
+ def build
125
+ if !File.exist?("gem_info.txt")
126
+ build_gem_info_txt
127
+ end
128
+ @github_urls.each do |url|
129
+ cleansed = url.gsub(/http[s]*:../, '').gsub('github.com','').gsub('github.io','').gsub("/", " ").gsub(".", "").strip
130
+ owner, repo = cleansed.split(" ")
131
+ if owner && repo
132
+ url = "https://api.github.com/repos/#{owner}/#{repo}"
133
+ # puts "#{owner} - #{repo} : #{url}"
134
+ directory = ".gempendencies/#{owner}/#{repo}"
135
+ `mkdir -p #{directory}`
136
+ file = "#{directory}/curl_result.json"
137
+
138
+ if File.exist?(file)
139
+ if (contents = File.read(file)).index("Moved Permanently")
140
+ json = JSON.parse(contents)
141
+ url = json['url']
142
+ elsif !contents.index("rate limit exceeded")
143
+ puts "skipping #{file}..."
144
+ json = JSON.parse(contents)
145
+ get_badges(json['html_url'], directory)
146
+ next
147
+ end
148
+ end
149
+
150
+ contents = get_repo_json(url, file)
151
+ json = JSON.parse(contents)
152
+ get_badges(json['html_url'], directory)
153
+ end
154
+ end
155
+ end # def build
156
+ end # class GemInfo
157
+ end # module Gempendencies
@@ -0,0 +1,3 @@
1
+ module Gempendencies
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gempendencies
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Darren Hicks
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Builds a comprehensive list of gems used by your project
70
+ email:
71
+ - darren.hicks@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/gempendencies
86
+ - bin/generate_gem_info.sh
87
+ - bin/setup
88
+ - gempendencies.gemspec
89
+ - lib/gempendencies.rb
90
+ - lib/gempendencies/gem_info.rb
91
+ - lib/gempendencies/version.rb
92
+ homepage: https://github.com/deevis/gempendencies
93
+ licenses:
94
+ - MIT
95
+ metadata:
96
+ homepage_uri: https://github.com/deevis/gempendencies
97
+ source_code_uri: https://github.com/deevis/gempendencies
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubygems_version: 3.1.2
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Builds a comprehensive list of gems used by your project
117
+ test_files: []