my_gems_summary 1.6 β†’ 2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -0
  3. data/lib/my_gems.rb +41 -6
  4. data/logo.png +0 -0
  5. data/mygems.gif +0 -0
  6. metadata +5 -3
  7. data/Gemfile.lock +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be5f3c6b9f4e1fa41daff660ab3745c0562c75eb8002d2f4b8c6ef1e8fa7052e
4
- data.tar.gz: d23db1d6b4f3c0129bc5e33d9787dcf43167696e64f13bff31497ca0d6bc214e
3
+ metadata.gz: b32f3bb93fd160b0a6a9de002ba664ee9382e41f0228fcc7166f79c69eb1f072
4
+ data.tar.gz: 0e4ab8fd17602db42550bfb5ea8ebd4bcd1e61870c1d1e1f99791b783c6180d5
5
5
  SHA512:
6
- metadata.gz: 95f72df671836e3292bf1cdda5c55e1159bdc98da72ed7af685e812df9a4400a52e818ed21a33c387b194aef5f3cca02ef34afaec2b92d46bed024d8f77fd356
7
- data.tar.gz: a3d4ced8d02f3343e5d42e7ce2659ff14833bd9574e088dedbbed3d0c8b400352ec700293086b72a899997d0b6e35a3c0df024f0233e2415f27bfb2cf96a6b79
6
+ metadata.gz: 9a0582694ff5d411efce960ea4c8a5ab487c374db33502348eb012b023988e0e5c5901fc16ee8e4e178a1a0a884ea583ad9b442415920b9ede4b56b396088105
7
+ data.tar.gz: dc71e831347ae639f1a8b27f7ce24af01c1cd24a8842fe7c6fa9cbc834800cf0dcd2a0c38fb6d48bbc94c2c49bac28eb7b5105a49d988072e8140949c7567f5d
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ <h1 align="center">Welcome to my-gems-summary-cli πŸ‘‹</h1>
2
+
3
+
4
+ <div align="center">
5
+ <img alt="logo" src="logo.png" />
6
+ </div>
7
+
8
+ <p>
9
+ <img alt="Version" src="https://img.shields.io/badge/version-4-blue.svg?cacheSeconds=2592000" />
10
+ <a href="https://twitter.com/kammzinho" target="_blank">
11
+ <img alt="Twitter: kammzinho" src="https://img.shields.io/twitter/follow/kammzinho.svg?style=social" />
12
+ </a>
13
+ </p>
14
+
15
+ > A gem to get a summary of your gems.
16
+
17
+
18
+ ## Install
19
+
20
+ ```sh
21
+ gem install my_gems_summary
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ```sh
27
+ mygems
28
+ ```
29
+
30
+ <div align="center">
31
+ <img alt="usage" src="mygems.gif" />
32
+ </div>
33
+
34
+
35
+
36
+ ## Author
37
+
38
+ πŸ‘€ **VinΓ­cius Kammradt**
39
+
40
+ * Website: https://kammradt.super.site
41
+ * Twitter: [@kammzinho](https://twitter.com/kammzinho)
42
+ * Github: [@kammradt](https://github.com/kammradt)
43
+ * LinkedIn: [@vinicius-kammradt](https://linkedin.com/in/vinicius-kammradt)
44
+
45
+ ## Show your support
46
+
47
+ Give a ⭐️ if this project helped you!
data/lib/my_gems.rb CHANGED
@@ -1,22 +1,57 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gems'
2
4
 
3
5
  GemDTO = Struct.new(:name, :downloads)
4
6
 
5
7
  module MyGems
8
+ def self.valid_credentials?
9
+ Gems.gems
10
+ rescue StandardError
11
+ puts 'πŸ₯Ί Opps, looks like we are missing your rubygems.org credentials 😭'
12
+ puts "πŸ₯Ί Let's authenticate 😭"
13
+
14
+ puts "πŸ’» Please run 'gem signin' and try again πŸ’»"
15
+ end
16
+
17
+ def self.my_gems
18
+ gems = Gems.gems.map { |gem| GemDTO.new(gem['name'], gem['downloads']) }
19
+ gems.sort_by(&:downloads).reverse
20
+ end
21
+
22
+ def self.valid_gems?(gems)
23
+ return gems unless gems.empty?
24
+
25
+ puts 'πŸ₯Ί Opps, looks like you have no gems 😭'
26
+ puts "πŸ₯Ί Let's add some πŸ’»"
27
+
28
+ puts "πŸ’» Please run 'gem build & gem push' and try again πŸ’»"
29
+ puts "πŸ’» Maybe you can find some funny stuff here github.com/kammradt πŸ’»"
30
+ end
31
+
32
+ def self.gem_with_longest_name(gems)
33
+ gems.max_by { |gem| gem.name.length }
34
+ end
35
+
6
36
  def self.show
7
37
  puts "⭐ Let's see if you're a star!⭐ "
38
+ return unless valid_credentials?
39
+
40
+ gems = my_gems
41
+ return unless valid_gems?(gems)
42
+
8
43
  puts "πŸ“š Here's your summary:"
9
44
  puts "\n"
10
45
 
11
- my_gems = Gems.gems.map { |gem| GemDTO.new(gem['name'], gem['downloads']) }
12
- gem_with_longest_name = my_gems.max_by { |gem| gem.name.length }
13
-
14
- my_gems.each do |gem|
15
- name_output = gem.name.ljust(gem_with_longest_name.first.length)
46
+ gems.each do |gem|
47
+ name_output = gem.name.ljust(gem_with_longest_name(gems).name.length)
16
48
  puts "πŸ›‘ #{name_output} πŸ” #{gem.downloads} downloads"
17
49
  end
50
+ puts "\n"
51
+
52
+ puts "πŸŽ‰ You're a star with #{gems.map(&:downloads).sum} total downloads πŸŽ‰"
18
53
 
19
54
  puts "\n"
20
- puts "Bye! See you soon πŸ‘‹πŸ‘‹πŸ‘‹"
55
+ puts 'Bye! See you soon πŸ‘‹πŸ‘‹πŸ‘‹'
21
56
  end
22
57
  end
data/logo.png ADDED
Binary file
data/mygems.gif ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_gems_summary
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.6'
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinicius Kammradt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-07 00:00:00.000000000 Z
11
+ date: 2022-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gems
@@ -33,10 +33,12 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - Gemfile
36
- - Gemfile.lock
36
+ - README.md
37
37
  - bin/mygems
38
38
  - bin/setup
39
39
  - lib/my_gems.rb
40
+ - logo.png
41
+ - mygems.gif
40
42
  homepage: https://github.com/kammradt/my-gems-summary-cli
41
43
  licenses:
42
44
  - MIT
data/Gemfile.lock DELETED
@@ -1,19 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- my_gems_summary (1.5)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- gems (1.2.0)
10
-
11
- PLATFORMS
12
- x86_64-linux
13
-
14
- DEPENDENCIES
15
- gems (~> 1.2)
16
- my_gems_summary!
17
-
18
- BUNDLED WITH
19
- 2.2.33