libyear-bundler 0.7.0 → 0.8.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: e4f90004a4a8f93453f73361a0e3415344017e83f55d10d625b0a3b69f1db74b
4
- data.tar.gz: 55d91c831ae79f5b44c6de0bcd2f68e550590d73d5004646c1da0163abbcebea
3
+ metadata.gz: 6e363af1df56aed65c6977f010e31514cc9e57e3b4270eacecff7005033554a3
4
+ data.tar.gz: 9293a7bc0a6708685577e28d85f43efeb15c3031f5432277be2fc593391a2d62
5
5
  SHA512:
6
- metadata.gz: e3b1346dbdc4986e539fba595f18e01a46fd03d647210b34a6810e2bd9ae61028ffa00eae7e4e2c4088f524368a2cc74950f5d79610ab6aa2bd93d5c4cdd9e6a
7
- data.tar.gz: 2196cc0fe1a16f2fd9ea4646eb7d07a227d58f07dc5f2cca3724c8ae4b08d4386adbdbc51f3364f2891745e7202b106348dabefed1734a6eb3b11c38823e4f17
6
+ metadata.gz: 4bed9a52de479d8a0479846cfa26beaf71b48c4df930a2e1bd86a021fabbb3b755e33148e6d2fcda14ab6297d304ade51331f38074d6e7a45ddab7f476ee0cb7
7
+ data.tar.gz: d190eb7367ccc794de8ba33ecf5794cb86b431a8b9227975d28c93f08f9930c1fd92e555e2280f720b9153647308a57694c2163a1599d43449b212e6ed56448c
@@ -23,23 +23,32 @@ module LibyearBundler
23
23
  begin
24
24
  dep = ::Bundler::Dependency.new(gem_name, gem_version)
25
25
  rescue ::Gem::Requirement::BadRequirementError => e
26
- $stderr.puts "Could not find release date for: #{gem_name}"
27
- $stderr.puts(e)
28
- $stderr.puts(
29
- "Maybe you used git in your Gemfile, which libyear doesn't support " \
30
- "yet. Contributions welcome."
31
- )
26
+ report_problem(gem_name, <<-MSG)
27
+ Could not find release date for: #{gem_name}
28
+ #{e}
29
+ Maybe you used git in your Gemfile, which libyear doesn't support yet. Contributions welcome.
30
+ MSG
32
31
  return nil
33
32
  end
34
33
  tuples, _errors = ::Gem::SpecFetcher.fetcher.search_for_dependency(dep)
35
34
  if tuples.empty?
36
- $stderr.puts "Could not find release date for: #{gem_name}"
35
+ report_problem(gem_name, "Could not find release date for: #{gem_name}")
37
36
  return nil
38
37
  end
39
38
  tup, source = tuples.first # Gem::NameTuple
40
39
  spec = source.fetch_spec(tup) # raises Gem::RemoteFetcher::FetchError
41
40
  spec.date.to_date
42
41
  end
42
+
43
+ private
44
+
45
+ def report_problem(gem_name, message)
46
+ @reported_gems ||= {}
47
+ @reported_gems[gem_name] ||= begin
48
+ $stderr.puts(message)
49
+ true
50
+ end
51
+ end
43
52
  end
44
53
 
45
54
  def installed_version
@@ -52,6 +52,10 @@ https://github.com/jaredbeck/libyear-bundler/
52
52
  opts.on('--grand-total', 'Return value for given metric(s)') do
53
53
  @options.send('grand_total?=', true)
54
54
  end
55
+
56
+ opts.on('--sort', 'Sort by selected metric(s), in descending order') do
57
+ @options.send('sort?=', true)
58
+ end
55
59
  end
56
60
  end
57
61
 
@@ -31,11 +31,12 @@ module LibyearBundler
31
31
  def to_h
32
32
  @_to_h ||=
33
33
  begin
34
+ gems = sorted_gems(@gems)
34
35
  summary = {
35
- gems: @gems,
36
+ gems: gems,
36
37
  sum_libyears: 0.0
37
38
  }
38
- @gems.each { |gem| increment_metrics_summary(gem, summary) }
39
+ gems.each { |gem| increment_metrics_summary(gem, summary) }
39
40
 
40
41
  begin
41
42
  increment_metrics_summary(@ruby, summary) if @ruby.outdated?
@@ -49,6 +50,20 @@ module LibyearBundler
49
50
 
50
51
  private
51
52
 
53
+ def sorted_gems(gems)
54
+ if @options.sort?
55
+ gems.sort_by do |gem|
56
+ [
57
+ (gem.libyears if @options.libyears?),
58
+ (gem.version_sequence_delta if @options.releases?),
59
+ (gem.version_number_delta if @options.versions?)
60
+ ].compact
61
+ end.reverse
62
+ else
63
+ gems
64
+ end
65
+ end
66
+
52
67
  def increment_metrics_summary(model, summary)
53
68
  increment_libyears(model, summary) if @options.libyears?
54
69
  increment_version_deltas(model, summary) if @options.versions?
@@ -1,3 +1,3 @@
1
1
  module LibyearBundler
2
- VERSION = "0.7.0".freeze
2
+ VERSION = "0.8.0".freeze
3
3
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ["jared@jaredbeck.com"]
12
12
  spec.summary = "A simple measure of dependency freshness"
13
13
  spec.homepage = "https://libyear.com"
14
- spec.licenses = ["GPL-3.0"]
14
+ spec.licenses = ["GPL-3.0-only"]
15
15
  spec.files = `git ls-files -z`.split("\x0").select do |f|
16
16
  f.start_with?('lib/') ||
17
17
  [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libyear-bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Beck
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-11 00:00:00.000000000 Z
11
+ date: 2024-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,7 +30,7 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3'
33
- description:
33
+ description:
34
34
  email:
35
35
  - jared@jaredbeck.com
36
36
  executables:
@@ -56,9 +56,9 @@ files:
56
56
  - libyear-bundler.gemspec
57
57
  homepage: https://libyear.com
58
58
  licenses:
59
- - GPL-3.0
59
+ - GPL-3.0-only
60
60
  metadata: {}
61
- post_install_message:
61
+ post_install_message:
62
62
  rdoc_options: []
63
63
  require_paths:
64
64
  - lib
@@ -73,8 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.2.20
77
- signing_key:
76
+ rubygems_version: 3.5.16
77
+ signing_key:
78
78
  specification_version: 4
79
79
  summary: A simple measure of dependency freshness
80
80
  test_files: []