usedby 0.4.1 → 0.5.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: 5c438d152cfc62f962534f416c092d33216c635777e2901079e04f967a4342b2
4
- data.tar.gz: 29c0012080e7ca8286181e1e0828548977fd89d032face141cfa0b986f05b1cc
3
+ metadata.gz: '08bffb7fcf4031b05950ca7575df9c788e1e6f588c9456233e38e4421e8ff9f4'
4
+ data.tar.gz: 61cc80ee5a51e964511ba496148386de9b33fed134f2374ccfcea48fd0480d19
5
5
  SHA512:
6
- metadata.gz: f2fc9eb47f71563a69bb27f0b129109a956be53884f02e2863c7dc1a76fc124d51debac9a7f1a23815cdcf41a739bf879faaffb29f0f4479380002a1cf99b513
7
- data.tar.gz: a8ed743d1e2a323344ed8dd4b402468d5433f291a7982fbc469f234ea36ddeb99ee0e036a8633f72feee57011b2b42cf77beafbb5dd273fa381e44929137fe25
6
+ metadata.gz: 148599e01faae245036e694fd0beda4a2d428d81f5f624af7fd45f8595fc9be7d39adc81796f461c4de2b2917f1cc5e557d8bc4a941c4610245b77f6027b4cd5
7
+ data.tar.gz: 22f66d1ee3dccef243e9109488b7f68515c0e8218ad8aab5be3acc0aa513fe990faea8130f15c455a186652340a544a85ca54ef41a2914e7020d27be7b6babf1
data/README.md CHANGED
@@ -19,12 +19,12 @@ gem install usedby
19
19
  ## Usage
20
20
 
21
21
  ```sh
22
- usedby GITHUB_ORGANIZATION [--direct] [--gems GEM1,GEM2,GEM3]
22
+ usedby GITHUB_ORGANIZATION [--direct] [--gems GEM1,GEM2,GEM3] [--order gems|projects]
23
23
  ```
24
24
 
25
25
  You will be securely prompted for a [GitHub Personal Access Token](https://github.com/settings/tokens).
26
26
 
27
- For example, running `usedby rails --direct --gems railties,rake` produces output
27
+ For example, running `usedby rails --gems railties,rake --order gems` produces output
28
28
  like the following:
29
29
 
30
30
  ```json
@@ -35,65 +35,31 @@ like the following:
35
35
  ],
36
36
  "4.0.0": [
37
37
  "prototype-rails/Gemfile.lock"
38
- ],
39
- "4.2.1": [
40
- "rails-perftest/Gemfile.lock"
41
- ],
42
- "4.2.10": [
43
- "rails-docs-server/test/fixtures/releases/v4.2.10/Gemfile.lock"
44
- ],
45
- "5.1.1": [
46
- "actioncable-examples/Gemfile.lock"
47
- ],
48
- "5.2.1": [
49
- "rails_fast_attributes/Gemfile.lock"
50
- ],
51
- "5.2.2": [
52
- "globalid/Gemfile.lock"
53
- ],
54
- "6.0.1": [
55
- "webpacker/Gemfile.lock"
56
- ],
57
- "6.0.2.1": [
58
- "rails-contributors/Gemfile.lock"
59
- ],
60
- "6.1.0.alpha": [
61
- "rails/Gemfile.lock"
62
38
  ]
63
39
  },
64
40
  "rake": {
65
41
  "0.9.2.2": [
66
- "commands/Gemfile.lock",
67
- "etagger/Gemfile.lock",
68
42
  "routing_concerns/Gemfile.lock"
69
43
  ],
70
44
  "10.1.0": [
71
45
  "prototype-rails/Gemfile.lock"
72
- ],
73
- "10.4.2": [
74
- "jquery-ujs/Gemfile.lock",
75
- "rails-perftest/Gemfile.lock"
76
- ],
77
- "10.5.0": [
78
- "rails_fast_attributes/Gemfile.lock",
79
- "record_tag_helper/Gemfile.lock"
80
- ],
81
- "12.0.0": [
82
- "actioncable-examples/Gemfile.lock",
83
- "rails-docs-server/test/fixtures/releases/v4.2.10/Gemfile.lock",
84
- "rails-dom-testing/Gemfile.lock"
85
- ],
86
- "12.3.2": [
87
- "globalid/Gemfile.lock"
88
- ],
89
- "13.0.0": [
90
- "webpacker/Gemfile.lock"
91
- ],
92
- "13.0.1": [
93
- "rails-contributors/Gemfile.lock",
94
- "rails/Gemfile.lock"
95
46
  ]
96
47
  }
97
48
  }
49
+ ```
50
+
51
+ On the other hand, running `usedby rails --gems railties,rake --order projects` produces output
52
+ like the following:
98
53
 
54
+ ```json
55
+ {
56
+ "prototype-rails": {
57
+ "railties": "4.0.0.beta",
58
+ "rake": "10.1.0"
59
+ },
60
+ "routing_concerns": {
61
+ "railties": "4.0.0.beta",
62
+ "rake": "0.9.2.2"
63
+ }
64
+ }
99
65
  ```
data/lib/usedby/cli.rb CHANGED
@@ -5,6 +5,7 @@ require 'io/console'
5
5
  require 'json'
6
6
  require 'optparse'
7
7
 
8
+ require 'bundler'
8
9
  require 'octokit'
9
10
 
10
11
  require 'usedby/version_ranges_intersection'
@@ -20,7 +21,6 @@ module Usedby
20
21
  Usage: usedby [options] GITHUB_ORGANIZATION
21
22
  USAGE
22
23
 
23
-
24
24
  def run
25
25
  parse_options
26
26
  if ARGV.size != 1
@@ -48,7 +48,12 @@ module Usedby
48
48
  merge!(gems, process_gemspec(content, "#{gemspec.repository.name}/#{gemspec.path}"))
49
49
  end
50
50
 
51
- output gems
51
+ case @options[:order]
52
+ when 'projects'
53
+ output_projects gems
54
+ else
55
+ output_gems gems
56
+ end
52
57
 
53
58
  0
54
59
  end
@@ -162,7 +167,7 @@ module Usedby
162
167
  end
163
168
  end
164
169
 
165
- def output(gems)
170
+ def output_gems(gems)
166
171
  sorted_gems = {}
167
172
  gems.sort.each do |gem, versions|
168
173
  sorted_gems[gem] = {}
@@ -173,6 +178,19 @@ module Usedby
173
178
  puts JSON.pretty_generate(sorted_gems)
174
179
  end
175
180
 
181
+ def output_projects(gems)
182
+ sorted_projects = {}
183
+ gems.sort.each do |gem, versions|
184
+ versions.sort.each do |version, projects|
185
+ projects.sort.each do |project|
186
+ sorted_projects[project] ||= {}
187
+ sorted_projects[project][gem] = version_ranges_to_s(version)
188
+ end
189
+ end
190
+ end
191
+ puts JSON.pretty_generate(sorted_projects.sort.to_h)
192
+ end
193
+
176
194
  def parse_options
177
195
  @options = { direct: false, ignore_paths: [] }
178
196
  OptionParser.new do |config|
@@ -183,14 +201,16 @@ module Usedby
183
201
  end
184
202
  config.on('-i', '--ignore-file [FILEPATH]',
185
203
  'Ignore projects included in file.') do |ignore_file|
186
-
187
204
  build_ignore_paths(@options[:ignore_paths], ignore_file)
188
205
  end
189
206
  config.on('-g', '--gems [GEM1,GEM2,GEM3]',
190
207
  'Consider only given gems.') do |gems|
191
-
192
208
  @options[:gems] = gems.split(',')
193
209
  end
210
+ config.on('-o', '--order gems|projects',
211
+ 'Order by gems or projects.') do |order|
212
+ @options[:order] = order
213
+ end
194
214
  config.version = Usedby::VERSION
195
215
  end.parse!
196
216
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Usedby
4
- VERSION = '0.4.1'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usedby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-09 00:00:00.000000000 Z
11
+ date: 2023-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -75,7 +75,7 @@ homepage: https://github.com/appfolio/usedby
75
75
  licenses:
76
76
  - BSD-2-Clause
77
77
  metadata: {}
78
- post_install_message:
78
+ post_install_message:
79
79
  rdoc_options: []
80
80
  require_paths:
81
81
  - lib
@@ -90,8 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.1.2
94
- signing_key:
93
+ rubygems_version: 3.1.6
94
+ signing_key:
95
95
  specification_version: 4
96
96
  summary: Discover all dependents of ruby gems across a github organization.
97
97
  test_files: []