gempendencies 0.1.1 → 0.1.2
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 +4 -4
 - data/lib/gempendencies/gem_info.rb +72 -33
 - data/lib/gempendencies/version.rb +1 -1
 - metadata +2 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b70280770630c5f7ce4fc9de8e18ea6494087edc5a6fb0b7a7405f3ae7b23f43
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7cada15f60bc71bdf0f94118c4b2f7b7af4e021f9bf30adf146e5549297b9a7c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ac18c854c678e1807925a6e37ed9c691962628edee7a7071ffba8d217a18ab9e3add3ec016e9f76c69b37e8565d63fd827e75bbeff6a467f6c879e71848e6a88
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3dea5c3a48155effd4a6ac9493142a6636293ac71300ab7e303c6574d79443932b59c5b143f322499f3cbe90070339e61fe9b72d423de98f06091107e2554455
         
     | 
| 
         @@ -34,23 +34,60 @@ module Gempendencies 
     | 
|
| 
       34 
34 
     | 
    
         
             
              class GemInfo
         
     | 
| 
       35 
35 
     | 
    
         
             
                def initialize
         
     | 
| 
       36 
36 
     | 
    
         
             
                  @domain_badge_labels = {}
         
     | 
| 
       37 
     | 
    
         
            -
                  # note - be sure to double backslash all the CLI backslashes
         
     | 
| 
       38 
     | 
    
         
            -
                  if File.exist?(".gempendencies/gem_info.txt")
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                  else
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                  end
         
     | 
| 
      
 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 
     | 
    
         
            +
                  #   build_gem_info_txt
         
     | 
| 
      
 42 
     | 
    
         
            +
                  # end
         
     | 
| 
       43 
43 
     | 
    
         
             
                end
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
                # uses bundler to build the gem_info.txt summarization of all gems used...
         
     | 
| 
       46 
46 
     | 
    
         
             
                def build_gem_info_txt
         
     | 
| 
       47 
47 
     | 
    
         
             
                  # https://gist.github.com/deevis/3211023e2b14e85df6ca908dbc642a2d
         
     | 
| 
       48 
48 
     | 
    
         
             
                  # https://gist.githubusercontent.com/deevis/3211023e2b14e85df6ca908dbc642a2d/raw/9fe1c9dfedc15b328cbe2e3f64f8198d56bb9795/generate_gem_info.sh
         
     | 
| 
       49 
     | 
    
         
            -
                  ` 
     | 
| 
      
 49 
     | 
    
         
            +
                  `mkdir -p .gempendencies`
         
     | 
| 
      
 50 
     | 
    
         
            +
                  gem_names = `bundle list`.split("\n").select{|s| s.index("*") && s.index("(")}.map{|s| s.split("*").last.split("(").first.gsub(" ","")}
         
     | 
| 
      
 51 
     | 
    
         
            +
                  count = gem_names.length
         
     | 
| 
      
 52 
     | 
    
         
            +
                  puts "Fetching 'gem info' for #{count} dependencies..."
         
     | 
| 
      
 53 
     | 
    
         
            +
                  gem_info = {}
         
     | 
| 
      
 54 
     | 
    
         
            +
                  license_counts = Hash.new(0)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  author_counts = Hash.new(0)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  gem_names.each_with_index do |gem_name,i| 
         
     | 
| 
      
 57 
     | 
    
         
            +
                    cmd = "gem info #{gem_name}"
         
     | 
| 
      
 58 
     | 
    
         
            +
                    puts "\n#{i+1}/#{count} #{cmd}"
         
     | 
| 
      
 59 
     | 
    
         
            +
                    info = `#{cmd}`
         
     | 
| 
      
 60 
     | 
    
         
            +
                    data = {}
         
     | 
| 
      
 61 
     | 
    
         
            +
                    info.split("\n").each do |line|
         
     | 
| 
      
 62 
     | 
    
         
            +
                      next unless line.index(":")
         
     | 
| 
      
 63 
     | 
    
         
            +
                      next if line.index("Installed at")
         
     | 
| 
      
 64 
     | 
    
         
            +
                      key, value = line.split(": ")
         
     | 
| 
      
 65 
     | 
    
         
            +
                      key = key.gsub('"', "").gsub(" ", "")
         
     | 
| 
      
 66 
     | 
    
         
            +
                      case key
         
     | 
| 
      
 67 
     | 
    
         
            +
                      when "Author", "Authors"
         
     | 
| 
      
 68 
     | 
    
         
            +
                        key = "Author"
         
     | 
| 
      
 69 
     | 
    
         
            +
                        value = value.split(", ")
         
     | 
| 
      
 70 
     | 
    
         
            +
                        value.each{|v| author_counts[v] += 1}
         
     | 
| 
      
 71 
     | 
    
         
            +
                      when "License", "Licenses"
         
     | 
| 
      
 72 
     | 
    
         
            +
                        key = "License"
         
     | 
| 
      
 73 
     | 
    
         
            +
                        value = value.split(", ")
         
     | 
| 
      
 74 
     | 
    
         
            +
                        value.each{|v| license_counts[v] += 1}
         
     | 
| 
      
 75 
     | 
    
         
            +
                      end            
         
     | 
| 
      
 76 
     | 
    
         
            +
                      data[key] = value
         
     | 
| 
      
 77 
     | 
    
         
            +
                    end
         
     | 
| 
      
 78 
     | 
    
         
            +
                    gem_info[gem_name] = data
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
                  File.open(".gempendencies/gem_info.yaml", "w") do |f|
         
     | 
| 
      
 81 
     | 
    
         
            +
                    f.puts gem_info.to_yaml
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
                  author_counts = Hash[author_counts.sort{|a,b| b[1] <=> a[1]}]
         
     | 
| 
      
 84 
     | 
    
         
            +
                  File.open(".gempendencies/author_info.yaml", "w"){|f| f.puts author_counts.to_yaml}
         
     | 
| 
      
 85 
     | 
    
         
            +
                  license_counts = Hash[license_counts.sort{|a,b| b[1] <=> a[1]}]
         
     | 
| 
      
 86 
     | 
    
         
            +
                  File.open(".gempendencies/license_info.yaml", "w"){|f| f.puts license_counts.to_yaml}
         
     | 
| 
       50 
87 
     | 
    
         
             
                end
         
     | 
| 
       51 
88 
     | 
    
         | 
| 
       52 
89 
     | 
    
         
             
                def github_urls
         
     | 
| 
       53 
     | 
    
         
            -
                  @github_urls = `grep "Homepage:" .gempendencies/gem_info. 
     | 
| 
      
 90 
     | 
    
         
            +
                  @github_urls = `grep "Homepage:" .gempendencies/gem_info.yaml | grep "github" | sed 's/.*page: \\(.*\\)/\\1/g'`.split("\n").uniq
         
     | 
| 
       54 
91 
     | 
    
         
             
                  #puts @github_urls
         
     | 
| 
       55 
92 
     | 
    
         
             
                  puts "Got #{@github_urls.length} github urls to process"
         
     | 
| 
       56 
93 
     | 
    
         
             
                  @github_urls
         
     | 
| 
         @@ -121,35 +158,37 @@ module Gempendencies 
     | 
|
| 
       121 
158 
     | 
    
         
             
                  contents
         
     | 
| 
       122 
159 
     | 
    
         
             
                end
         
     | 
| 
       123 
160 
     | 
    
         | 
| 
       124 
     | 
    
         
            -
                def build
         
     | 
| 
       125 
     | 
    
         
            -
                  if !File.exist?("gem_info. 
     | 
| 
      
 161 
     | 
    
         
            +
                def build(load_github_metadata = false)
         
     | 
| 
      
 162 
     | 
    
         
            +
                  if !File.exist?(".gempendencies/gem_info.yaml")
         
     | 
| 
       126 
163 
     | 
    
         
             
                    build_gem_info_txt
         
     | 
| 
       127 
164 
     | 
    
         
             
                  end
         
     | 
| 
       128 
     | 
    
         
            -
                   
     | 
| 
       129 
     | 
    
         
            -
                     
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
                       
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
                        if  
     | 
| 
       140 
     | 
    
         
            -
                           
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
                           
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
      
 165 
     | 
    
         
            +
                  if load_github_metadata
         
     | 
| 
      
 166 
     | 
    
         
            +
                    @github_urls.each do |url|
         
     | 
| 
      
 167 
     | 
    
         
            +
                      cleansed = url.gsub(/http[s]*:../, '').gsub('github.com','').gsub('github.io','').gsub("/", " ").gsub(".", "").strip
         
     | 
| 
      
 168 
     | 
    
         
            +
                      owner, repo = cleansed.split(" ")
         
     | 
| 
      
 169 
     | 
    
         
            +
                      if owner && repo
         
     | 
| 
      
 170 
     | 
    
         
            +
                        url = "https://api.github.com/repos/#{owner}/#{repo}"
         
     | 
| 
      
 171 
     | 
    
         
            +
                        # puts "#{owner} - #{repo}   :  #{url}"
         
     | 
| 
      
 172 
     | 
    
         
            +
                        directory = ".gempendencies/#{owner}/#{repo}"
         
     | 
| 
      
 173 
     | 
    
         
            +
                        `mkdir -p #{directory}`
         
     | 
| 
      
 174 
     | 
    
         
            +
                        file = "#{directory}/curl_result.json"
         
     | 
| 
      
 175 
     | 
    
         
            +
                        
         
     | 
| 
      
 176 
     | 
    
         
            +
                        if File.exist?(file)
         
     | 
| 
      
 177 
     | 
    
         
            +
                          if (contents = File.read(file)).index("Moved Permanently")
         
     | 
| 
      
 178 
     | 
    
         
            +
                            json = JSON.parse(contents)
         
     | 
| 
      
 179 
     | 
    
         
            +
                            url = json['url']
         
     | 
| 
      
 180 
     | 
    
         
            +
                          elsif !contents.index("rate limit exceeded")
         
     | 
| 
      
 181 
     | 
    
         
            +
                            puts "skipping #{file}..."
         
     | 
| 
      
 182 
     | 
    
         
            +
                            json = JSON.parse(contents)
         
     | 
| 
      
 183 
     | 
    
         
            +
                            get_badges(json['html_url'], directory)
         
     | 
| 
      
 184 
     | 
    
         
            +
                            next
         
     | 
| 
      
 185 
     | 
    
         
            +
                          end
         
     | 
| 
       147 
186 
     | 
    
         
             
                        end
         
     | 
| 
       148 
     | 
    
         
            -
                      end
         
     | 
| 
       149 
187 
     | 
    
         | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
      
 188 
     | 
    
         
            +
                        contents = get_repo_json(url, file)
         
     | 
| 
      
 189 
     | 
    
         
            +
                        json = JSON.parse(contents)
         
     | 
| 
      
 190 
     | 
    
         
            +
                        get_badges(json['html_url'], directory)
         
     | 
| 
      
 191 
     | 
    
         
            +
                      end
         
     | 
| 
       153 
192 
     | 
    
         
             
                    end
         
     | 
| 
       154 
193 
     | 
    
         
             
                  end
         
     | 
| 
       155 
194 
     | 
    
         
             
                end # def build
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: gempendencies
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Darren Hicks
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2021-04- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-04-14 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: nokogiri
         
     | 
| 
         @@ -71,7 +71,6 @@ email: 
     | 
|
| 
       71 
71 
     | 
    
         
             
            - darren.hicks@gmail.com
         
     | 
| 
       72 
72 
     | 
    
         
             
            executables:
         
     | 
| 
       73 
73 
     | 
    
         
             
            - gempendencies
         
     | 
| 
       74 
     | 
    
         
            -
            - generate_gem_info.sh
         
     | 
| 
       75 
74 
     | 
    
         
             
            extensions: []
         
     | 
| 
       76 
75 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       77 
76 
     | 
    
         
             
            files:
         
     |