whatthegem 0.0.3 → 0.0.4

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: 2b11abd3dbf7f0939a89f985e7f1b1245f823443475a8d5154186fed66d93d9e
4
- data.tar.gz: 68b202c777628a18986892fa5551e83edee71aa7d1d8ab44329a4d9d9f85395f
3
+ metadata.gz: e42042e156dc134be8400ca0a1cd3473b4129125618bce15f4b83be628ae8d4b
4
+ data.tar.gz: 39a4c8d52e4d340b2f76fa54714b764585b8ea487a27972d35878bdfb79b956e
5
5
  SHA512:
6
- metadata.gz: 5f1040f308c12c8d92c349d6a65e3aea1688f8545f7d8fe7ffff1e4438b2887a136c8e93e44e87a3ea138ad6412a30837f18641f4511568f393c61f6d6542351
7
- data.tar.gz: 877d03c176fa0b098d6c4cfab6d48f445d1678545f79f75e951d8f6e09811c94bcd4a0d324c5f6064cc587409a663bc0ec16181d67b5d6205fe7be90c2767a53
6
+ metadata.gz: b66a20180176b7b227c91f58133e966caab4dc2fe274849b2a29a5cd2c79a755560b5196dc706f7385ab39ea55269d9875bae7695342f615ccd6467ace0286a0
7
+ data.tar.gz: 3cc55b4c3a85502f9774fe0acd92a18922ee652c7099adff8c89f3e067161fbc8cff9ea8a6646041cacf93b4d9293b3c23be58d906c21a25f30a7c7e1f486c19
@@ -14,7 +14,8 @@ module WhatTheGem
14
14
  end
15
15
 
16
16
  def versions
17
- releases.map { |tag_name:, name:, body:, **|
17
+ releases.map { |rel|
18
+ tag_name, name, body = rel.fetch_values(:tag_name, :name, :body)
18
19
  Version.new(
19
20
  number: tag_name[VERSION_LINE_REGEXP, :version],
20
21
  header: name.then.reject(&:empty?).first || tag_name,
@@ -15,6 +15,10 @@ module WhatTheGem
15
15
  req(:versions)
16
16
  end
17
17
 
18
+ memoize def stable_versions
19
+ req(:versions).reject { |v| v[:prerelease] }
20
+ end
21
+
18
22
  memoize def reverse_dependencies
19
23
  req(:reverse_dependencies)
20
24
  end
@@ -26,4 +30,4 @@ module WhatTheGem
26
30
  end
27
31
  end
28
32
  end
29
- end
33
+ end
@@ -49,7 +49,7 @@ module WhatTheGem
49
49
  def ago_text(tm)
50
50
  diff = TimeCalc.now.-(tm).factorize
51
51
  unit, num = diff.detect { |_, v| !v.zero? }
52
- "#{num} #{unit} ago"
52
+ "#{num} #{unit}#{'s' unless num == 1} ago"
53
53
  end
54
54
  end
55
55
  end
@@ -8,6 +8,9 @@ module WhatTheGem
8
8
 
9
9
  TEMPLATE = Template.parse(<<~INFO)
10
10
  Latest version: {{info.version}} ({{age}})
11
+ {% if prerelease %}
12
+ Prerelease: {{prerelease.number}} ({{prerelease.age}})
13
+ {% endif %}
11
14
  Installed versions: {% if specs %}{{ specs | map:"version" | join: ", "}}{% else %}—{% endif %}
12
15
  {% if current %}
13
16
  Most recent installed at: {{current.dir}}
@@ -26,6 +29,7 @@ module WhatTheGem
26
29
  {
27
30
  info: gem.rubygems.info,
28
31
  age: age,
32
+ prerelease: prerelease,
29
33
  specs: specs,
30
34
  current: specs.last,
31
35
  bundled: gem.bundled.to_h,
@@ -36,9 +40,14 @@ module WhatTheGem
36
40
  private
37
41
 
38
42
  def age
39
- gem.rubygems.versions
40
- .first&.dig(:created_at)
41
- &.then(&Time.method(:parse))&.then(&I.method(:ago_text))
43
+ version = gem.rubygems.stable_versions.first or return
44
+ version.dig(:created_at).then(&Time.method(:parse)).then(&I.method(:ago_text))
45
+ end
46
+
47
+ def prerelease
48
+ gem.rubygems.versions.first
49
+ &.then { |ver| ver if ver[:prerelease] }
50
+ &.then { |ver| ver.merge(age: I.ago_text(Time.parse(ver[:created_at]))) }
42
51
  end
43
52
 
44
53
  def specs
@@ -55,4 +64,4 @@ module WhatTheGem
55
64
  Command.registry.values.-([self.class]).map(&:meta).map(&:to_h)
56
65
  end
57
66
  end
58
- end
67
+ end
@@ -20,7 +20,7 @@ module WhatTheGem
20
20
 
21
21
  metric 'Downloads', :rubygems, :info, :downloads, thresholds: [5_000, 10_000]
22
22
  metric 'Latest version',
23
- :rubygems, :versions, 0, :created_at,
23
+ :rubygems, :stable_versions, 0, :created_at,
24
24
  thresholds: [T.now.-(1, :year), T.now.-(2, :months)],
25
25
  &Time.method(:parse)
26
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whatthegem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Shepelev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-10 00:00:00.000000000 Z
11
+ date: 2020-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit