repofetch 0.4.0 → 0.4.2.pre.rc.3

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: 82e31a1aff66491aa6ee4f0ce862ed960876a5762fe7b870536d2a4b6f3ab2a2
4
- data.tar.gz: cdd76b64181cfa253e87be1633ab3f16b370462de69d47e4d1b4468eb6e5f0c2
3
+ metadata.gz: f023092a0a4175633900e4bd9da512c5287a781be907cf57a8971a1fdd7fda6c
4
+ data.tar.gz: 6d1a8f7e801bf4f4e228249a650f5270dc38153bdfa9a7c32771dd02d01c098b
5
5
  SHA512:
6
- metadata.gz: 798b248c171c24dc046904cbd76fd0b9a8d81a32d73244d657881e815f6801f464018a518990fb31e64429c756cf090c97a2d3ec77fe4200703d10c85e07ddfc
7
- data.tar.gz: 170af910f544c77a35eb66a8f7155a0105e7a3493590b875ee38d3787a158f6fc6815b73ecdae5d53f474ab5906d51636813c70c0f5e3aa19f1be65549487ba1
6
+ metadata.gz: 3fc54f3354a0f0b531eea8a183391ac839244c714546439f4e21d5d42e4d9233ffc17150149b8c48c29fa1adcb21b7c5d46a504855daffbf9e36c10ab8710d1a
7
+ data.tar.gz: 29a97740e37ea30bd2f5017f42a0647c3cb944bd811e4d17831fb1d9fc55fe125c9db1d54aa4c9c4c14bef271ae850e2a6b0af067c78604006cc3aa5b939fd25
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Changelog
2
2
 
3
+ :warning: Further updates will be tracked in the [release notes](https://github.com/spenserblack/repofetch/releases).
4
+
3
5
  ## [Unreleased]
4
6
 
5
7
  ### Other
data/CONTRIBUTING.md CHANGED
@@ -19,7 +19,11 @@ bundle exec overcommit --install
19
19
  configuration files.
20
20
 
21
21
  You can view an officially supported plugin, like `Repofetch::Github`, as an
22
- example for writing a plugin.
22
+ example for writing a plugin. Some information for writing a plugin is provided
23
+ below, but you can view more information from the generated documentation. Versioned
24
+ documentation is deployed to [rdoc.info](https://rubydoc.info/gems/repofetch), and
25
+ bleeding-edge documentation is deployed to
26
+ [GitHub Pages](https://spenserblack.github.io/repofetch/).
23
27
 
24
28
  The easiest way to set up a plugin is to inherit from `Repofetch::Plugin`, which
25
29
  will provide several helper methods that repofetch relies on to construct the
@@ -86,11 +90,11 @@ class MyCoolPlugin < Repofetch::Plugin
86
90
  @arg_count = arg_count
87
91
  end
88
92
 
89
- def self.from_git(git, args, _config)
93
+ def self.from_git(git, args)
90
94
  new(true, args.length)
91
95
  end
92
96
 
93
- def self.from_args(args, _config)
97
+ def self.from_args(args)
94
98
  new(false, args.length)
95
99
  end
96
100
 
@@ -120,4 +124,10 @@ end
120
124
  MyCoolPlugin.register
121
125
  ```
122
126
 
127
+ ### Guidelines
128
+
129
+ - For ASCII art, try to avoid using explicit black and white colors for negative and positive space.
130
+ This can harm compatibility between light and dark terminals. Instead, simply use whitespace for
131
+ negative space, and uncolored text for positive space.
132
+
123
133
  [git-base]: https://www.rubydoc.info/github/ruby-git/ruby-git/Git/Base
data/CREDITS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Credits
2
2
 
3
- A special thanks to all listed below!
3
+ A special thanks to all listed below ([emoji key](https://allcontributors.org/docs/emoji-key))!
4
4
 
5
5
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
6
6
  <!-- prettier-ignore-start -->
@@ -9,6 +9,7 @@ A special thanks to all listed below!
9
9
  <tbody>
10
10
  <tr>
11
11
  <td align="center"><a href="http://orhun.dev"><img src="https://avatars.githubusercontent.com/u/24392180?v=4?s=100" width="100px;" alt="Orhun Parmaksız"/><br /><sub><b>Orhun Parmaksız</b></sub></a><br /><a href="#bug-orhun" title="Bug reports">🐛</a> <a href="#code-orhun" title="Code">💻</a></td>
12
+ <td align="center"><a href="https://github.com/mmdbalkhi"><img src="https://avatars.githubusercontent.com/u/65954744?v=4?s=100" width="100px;" alt="komeil Parseh"/><br /><sub><b>komeil Parseh</b></sub></a><br /><a href="#platform-mmdbalkhi" title="Packaging/porting to new platform">📦</a></td>
12
13
  <td align="center"><a href="https://github.com/0323pin"><img src="https://avatars.githubusercontent.com/u/90570748?v=4?s=100" width="100px;" alt="pin"/><br /><sub><b>pin</b></sub></a><br /><a href="#platform-0323pin" title="Packaging/porting to new platform">📦</a></td>
13
14
  </tr>
14
15
  </tbody>
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- repofetch (0.4.0)
4
+ repofetch (0.4.2.pre.rc.3)
5
5
  actionview (~> 7.0, >= 7.0.4)
6
6
  dotenv (~> 2.8)
7
7
  faraday-retry (~> 2.0)
@@ -34,25 +34,25 @@ GEM
34
34
  docile (1.4.0)
35
35
  dotenv (2.8.1)
36
36
  erubi (1.11.0)
37
- faraday (2.7.1)
37
+ faraday (2.7.2)
38
38
  faraday-net_http (>= 2.0, < 3.1)
39
39
  ruby2_keywords (>= 0.0.4)
40
40
  faraday-net_http (3.0.2)
41
41
  faraday-retry (2.0.0)
42
42
  faraday (~> 2.0)
43
- git (1.12.0)
43
+ git (1.13.0)
44
44
  addressable (~> 2.8)
45
45
  rchardet (~> 1.8)
46
46
  i18n (1.12.0)
47
47
  concurrent-ruby (~> 1.0)
48
48
  iniparse (1.5.0)
49
49
  json (2.6.2)
50
- loofah (2.19.0)
50
+ loofah (2.19.1)
51
51
  crass (~> 1.0.2)
52
52
  nokogiri (>= 1.5.9)
53
53
  mini_portile2 (2.8.0)
54
54
  minitest (5.16.3)
55
- nokogiri (1.13.9)
55
+ nokogiri (1.13.10)
56
56
  mini_portile2 (~> 2.8.0)
57
57
  racc (~> 1.4)
58
58
  octokit (6.0.1)
@@ -65,13 +65,13 @@ GEM
65
65
  parallel (1.22.1)
66
66
  parser (3.1.3.0)
67
67
  ast (~> 2.4.1)
68
- public_suffix (5.0.0)
69
- racc (1.6.0)
68
+ public_suffix (5.0.1)
69
+ racc (1.6.1)
70
70
  rails-dom-testing (2.0.3)
71
71
  activesupport (>= 4.2.0)
72
72
  nokogiri (>= 1.6)
73
- rails-html-sanitizer (1.4.3)
74
- loofah (~> 2.3)
73
+ rails-html-sanitizer (1.4.4)
74
+ loofah (~> 2.19, >= 2.19.1)
75
75
  rainbow (3.1.1)
76
76
  rake (13.0.6)
77
77
  rchardet (1.8.0)
@@ -126,6 +126,9 @@ GEM
126
126
  tzinfo (2.0.5)
127
127
  concurrent-ruby (~> 1.0)
128
128
  unicode-display_width (2.3.0)
129
+ webrick (1.7.0)
130
+ yard (0.9.28)
131
+ webrick (~> 1.7.0)
129
132
 
130
133
  PLATFORMS
131
134
  ruby
@@ -142,6 +145,7 @@ DEPENDENCIES
142
145
  rubocop-rspec (~> 2.13)
143
146
  simplecov (~> 0.21)
144
147
  simplecov-cobertura (~> 2.1)
148
+ yard (~> 0.9.28)
145
149
 
146
150
  BUNDLED WITH
147
151
  2.1.2
data/Makefile CHANGED
@@ -1,7 +1,13 @@
1
- .PHONY: install
2
-
3
1
  repofetch.gem: repofetch.gemspec lib/** exe/**
4
2
  gem build -o repofetch.gem repofetch.gemspec
5
3
 
4
+ demos: tapes/*
5
+ $(foreach tape,$(wildcard tapes/*),vhs $(tape);)
6
+
7
+ .PHONY: doc
8
+ doc:
9
+ bundle exec yardoc
10
+
11
+ .PHONY: install
6
12
  install: repofetch.gem
7
13
  gem install repofetch.gem
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # `repofetch`
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/repofetch.svg)](https://badge.fury.io/rb/repofetch)
3
4
  [![GitHub contributors (via allcontributors.org)](https://img.shields.io/github/all-contributors/spenserblack/repofetch)](./CREDITS.md)
4
5
  ![CI](https://github.com/spenserblack/repofetch/workflows/CI/badge.svg)
5
6
  [![CodeQL](https://github.com/spenserblack/repofetch/actions/workflows/codeql.yml/badge.svg)](https://github.com/spenserblack/repofetch/actions/workflows/codeql.yml)
@@ -7,6 +8,12 @@
7
8
 
8
9
  Fetch details about your remote repository.
9
10
 
11
+ ## Usage
12
+
13
+ ![basic demo](./demos/demo.gif)
14
+
15
+ ![advanced plugin usage](./demos/github-plugin.gif)
16
+
10
17
  ## Description
11
18
 
12
19
  repofetch is a CLI tool to fetch stats (think [neofetch] or
@@ -16,7 +23,32 @@ repofetch. With 3rd-party plugins, however, it can support other types of output
16
23
 
17
24
  ## Installation
18
25
 
19
- ### NetBSD (version <= 0.3.3)
26
+ ### Via RubyGems.org
27
+
28
+ ```bash
29
+ gem install repofetch
30
+ ```
31
+
32
+ ### Via AUR
33
+
34
+ If you are using an Arch machine, you can install repofetch from the [Aur](https://aur.archlinux.org).
35
+
36
+ ```
37
+ yay -S ruby-repofetch
38
+ ```
39
+
40
+ ### Installing Version `< 0.4.0`
41
+
42
+ Version 0.3.3 and lower was a different implementation written in Rust. While `>= 0.4.0` is unstable
43
+ and likely buggy, you may want to use a lower version.
44
+
45
+ #### Via [Crates.io](https://crates.io/crates/repofetch)
46
+
47
+ ```bash
48
+ cargo install repofetch
49
+ ```
50
+
51
+ #### Via NetBSD
20
52
 
21
53
  Pre-compiled binaries are available from the [official repositories](https://pkgsrc.se/sysutils/repofetch)
22
54
  To install this, simply run:
@@ -57,10 +89,19 @@ plugins:
57
89
 
58
90
  ```dotenv
59
91
  # .repofetch.env
60
- # Assuming you have gh (the GitHub CLI) installed
92
+ GITHUB_TOKEN=my-token-abcdefg
93
+
94
+ # Yes, command substitution is supported!
61
95
  GITHUB_TOKEN=$(gh auth token)
62
96
  ```
63
97
 
98
+ ## Notes on Rust Implementation (Version `< 0.4.0`)
99
+
100
+ I switched from Rust to Ruby to rewrite this project to use and support
101
+ plugins. I won't develop new features for the Rust implementation, but I may
102
+ fix bugs, and I'll review pull requests. The Rust implementation is on the
103
+ `rust` branch.
104
+
64
105
  [dotenv]: https://github.com/bkeepers/dotenv
65
106
  [neofetch]: https://github.com/dylanaraps/neofetch
66
107
  [onefetch]: https://github.com/o2sh/onefetch
data/RELEASE_NOTES ADDED
@@ -0,0 +1,6 @@
1
+ 0.4.2-rc.3
2
+
3
+ ## Other
4
+
5
+ - Deploy built gem as GitHub release asset for each release
6
+ - Publish gem with GitHub Actions
data/Rakefile CHANGED
@@ -5,11 +5,13 @@ require 'rake'
5
5
 
6
6
  require 'rspec/core/rake_task'
7
7
  require 'rubocop/rake_task'
8
+ require 'yard'
8
9
 
9
10
  RSpec::Core::RakeTask.new(:spec)
10
11
  RuboCop::RakeTask.new(:format) do |t|
11
12
  t.requires << 'rubocop-rspec'
12
13
  end
14
+ YARD::Rake::YardocTask.new(:doc)
13
15
 
14
16
  desc 'Run tests'
15
17
  task default: %i[format spec]
data/exe/repofetch CHANGED
@@ -1,60 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'git'
5
- require 'optparse'
6
4
  require 'repofetch'
7
- require 'repofetch/config'
5
+ require 'repofetch/cli'
8
6
  require 'repofetch/env'
9
7
 
10
8
  Repofetch::Env.load
11
- config = Repofetch::Config.load!
12
-
13
- config.plugins.each { |plugin| require plugin }
14
-
15
- options = {
16
- plugin: nil,
17
- repository: '.'
18
- }
19
-
20
- available_plugins = Repofetch.plugins.to_h { |plugin| [plugin.name, plugin] }
21
-
22
- command = OptionParser.new do |opts|
23
- opts.banner = 'Usage: repofetch [options] -- [plugin arguments]'
24
-
25
- opts.on('-r', '--repository PATH', 'Use the provided repository. Defaults to the current directory.') do |path|
26
- options[:repository] = path
27
- end
28
-
29
- opts.on('-p', '--plugin PLUGIN', 'Use the specified plugin') do |plugin|
30
- options[:plugin] = available_plugins[plugin]
31
- end
32
-
33
- Repofetch.plugins.each do |plugin|
34
- opts.on("--#{plugin.name.sub(/::/, '-').downcase}", "Shortcut for --plugin #{plugin.name}") do
35
- options[:plugin] = plugin
36
- end
37
- end
38
-
39
- opts.separator ''
40
- dotenv_paths = Repofetch::Env::DOTENV_PATHS.join(', ')
41
- opts.separator "The following dotenv files can be used to set environment variables: #{dotenv_paths}"
42
- opts.separator ''
43
- opts.separator "You config file is at #{Repofetch::Config::PATH}"
44
- opts.separator "Installed plugins: #{available_plugins.keys.join(', ')}"
45
- end
46
-
47
- command.parse!
48
-
49
- git = Git.open(options[:repository])
50
- plugin_class = options[:plugin]
51
- # NOTE: If the user explicitly selected a plugin, then it is constructed from CLI args.
52
- # Otherwise, we try to build it from the repository.
53
- begin
54
- plugin = plugin_class.nil? ? Repofetch.get_plugin(git, ARGV, config) : plugin_class.from_args(ARGV, config)
55
- rescue ArgumentError => e
56
- warn e
57
- exit 1
58
- end
59
-
60
- puts plugin
9
+ Repofetch.load_config!
10
+ exit Repofetch::CLI.new.start
@@ -2,3 +2,4 @@
2
2
  # vim: set ft=yaml:
3
3
  plugins:
4
4
  - 'repofetch/github'
5
+ emojis: true
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git'
4
+ require 'optparse'
5
+ require 'repofetch'
6
+ require 'repofetch/config'
7
+
8
+ class Repofetch
9
+ # Command line interface for repofetch.
10
+ class CLI
11
+ attr_reader :repository_path, :plugin
12
+
13
+ # Define the command line interface.
14
+ #
15
+ # @param [Repofetch::Config] config The configuration to use. Defaults to +Repofetch.config+.
16
+ # @param [Array<String>] args Command line arguments.
17
+ def initialize(config = nil, args = ARGV)
18
+ @config = config || Repofetch.config
19
+ @args = args
20
+ @repository_path = '.'
21
+ end
22
+
23
+ # Run the command line interface.
24
+ #
25
+ # @return [Integer] The exit code.
26
+ def start
27
+ load_plugins
28
+ define_options.parse!(@args)
29
+
30
+ begin
31
+ plugin = new_plugin
32
+ rescue ArgumentError => e
33
+ warn e
34
+ return 1
35
+ end
36
+
37
+ puts plugin
38
+ 0
39
+ end
40
+
41
+ def define_options
42
+ OptionParser.new do |opts|
43
+ opts.banner = 'Usage: repofetch [options] -- [plugin arguments]'
44
+
45
+ add_repository_options(opts)
46
+ add_plugin_options(opts)
47
+ add_options_notes(opts)
48
+ end
49
+ end
50
+
51
+ def load_plugins
52
+ @config.plugins.each { |plugin| require plugin }
53
+ end
54
+
55
+ def new_plugin
56
+ return @plugin.from_args(@args) unless @plugin.nil?
57
+
58
+ git = Git.open(@repository_path)
59
+ Repofetch.get_plugin(git, @args)
60
+ end
61
+
62
+ private
63
+
64
+ def add_repository_options(opts)
65
+ opts.on('-r', '--repository PATH', 'Use the provided repository. Defaults to the current directory.') do |path|
66
+ @repository_path = path
67
+ end
68
+ end
69
+
70
+ def add_plugin_options(opts)
71
+ opts.on('-p', '--plugin PLUGIN', 'Use the specified plugin.') do |plugin|
72
+ @plugin = available_plugins[plugin]
73
+ end
74
+
75
+ Repofetch.plugins.each do |plugin|
76
+ opts.on("--#{plugin.name.sub(/::/, '-').downcase}", "Shortcut for --plugin #{plugin.name}") do
77
+ @plugin = plugin
78
+ end
79
+ end
80
+ end
81
+
82
+ def add_options_notes(opts)
83
+ opts.separator ''
84
+ dotenv_paths = Repofetch::Env.dotenv_paths.join(', ')
85
+ opts.separator "The following dotenv files can be used to set environment variables: #{dotenv_paths}"
86
+ opts.separator ''
87
+ opts.separator "You config file is at #{Repofetch::Config.path}"
88
+ opts.separator "Installed plugins: #{available_plugins.keys.join(', ')}"
89
+ end
90
+
91
+ def available_plugins
92
+ Repofetch.plugins.to_h { |plugin| [plugin.name, plugin] }
93
+ end
94
+ end
95
+ end
@@ -5,34 +5,47 @@ require 'yaml'
5
5
  class Repofetch
6
6
  # Utilities for managing config.
7
7
  class Config
8
- PATH = File.expand_path('.repofetch.yml', Dir.home)
9
8
  DEFAULT_CONFIG = File.read(File.expand_path('DEFAULT_CONFIG', __dir__))
10
9
 
11
10
  # Loads from config file.
12
11
  def self.load
13
- new(File.read(PATH))
12
+ new(File.read(path))
13
+ end
14
+
15
+ # The path to the config file.
16
+ def self.path
17
+ File.expand_path('.repofetch.yml', Dir.home)
14
18
  end
15
19
 
16
20
  # Loads from a config file if it exists. If it doesn't, it writes the config file,
17
21
  # then creates a default.
18
22
  def self.load!
19
- if File.exist?(PATH)
23
+ if File.exist?(path)
20
24
  self.load
21
25
  else
22
- File.write(PATH, DEFAULT_CONFIG)
26
+ File.write(path, DEFAULT_CONFIG)
23
27
  new(DEFAULT_CONFIG)
24
28
  end
25
29
  end
26
30
 
27
31
  # @param config_yaml [String] a YAML string
28
- def initialize(config_yaml = DEFAULT_CONFIG)
29
- @config = YAML.safe_load(config_yaml, symbolize_names: true)
32
+ def initialize(config_yaml = '')
33
+ @config = YAML.safe_load(config_yaml, symbolize_names: true) || {}
30
34
  end
31
35
 
32
36
  def plugins
33
37
  @config[:plugins] || []
34
38
  end
35
39
 
40
+ # Should emojis be shown
41
+ def emojis?
42
+ @config[:emojis].nil? || @config[:emojis]
43
+ end
44
+
45
+ def emojis=(emojis)
46
+ @config[:emojis] = emojis
47
+ end
48
+
36
49
  def [](key)
37
50
  @config[key]
38
51
  end
data/lib/repofetch/env.rb CHANGED
@@ -6,10 +6,13 @@ class Repofetch
6
6
  # Environment variable manager. Basically a wrapper around dotenv.
7
7
  class Env
8
8
  DOTENV_NAMES = ['repofetch.env', '.repofetch.env'].freeze
9
- DOTENV_PATHS = DOTENV_NAMES.map { |name| File.expand_path(name, Dir.home) }
10
9
 
11
10
  def self.load
12
- DOTENV_PATHS.each { |dotenv| Dotenv.load(dotenv) }
11
+ dotenv_paths.each { |dotenv| Dotenv.load(dotenv) }
12
+ end
13
+
14
+ def self.dotenv_paths
15
+ DOTENV_NAMES.map { |name| File.expand_path(name, Dir.home) }
13
16
  end
14
17
  end
15
18
  end
@@ -64,7 +64,9 @@ class Repofetch
64
64
  end
65
65
 
66
66
  # Creates an instance from a +Git::Base+ instance.
67
- def self.from_git(git, args, _config)
67
+ #
68
+ # @raise [ArgumentError] if this plugin was selected *and* arguments were passed.
69
+ def self.from_git(git, args)
68
70
  # TODO: Raise a better exception than ArgumentError
69
71
  raise ArgumentError, 'Explicitly activate this plugin to CLI arguments' unless args.empty?
70
72
 
@@ -74,7 +76,9 @@ class Repofetch
74
76
  end
75
77
 
76
78
  # Creates an instance from CLI args and configuration.
77
- def self.from_args(args, _config)
79
+ #
80
+ # @raise [ArgumentError] if +args+ couldn't be parsed.
81
+ def self.from_args(args)
78
82
  parser = OptionParser.new do |opts|
79
83
  opts.banner = 'Usage: <plugin activation> -- [options] OWNER/REPOSITORY'
80
84
  opts.separator ''
@@ -3,7 +3,7 @@
3
3
  class Repofetch
4
4
  # Provides uncategorized utilities.
5
5
  class Util
6
- # Cleans a string with style parameters (e.g. "%{green}OK" -> "OK")
6
+ # Cleans a string with style parameters (e.g. +"%{green}OK"+ -> +"OK"+)
7
7
  def self.clean_s(str)
8
8
  str.gsub(/%{[\w\d]+?}/, '')
9
9
  end
data/lib/repofetch.rb CHANGED
@@ -16,9 +16,20 @@ class Repofetch
16
16
  @plugins = []
17
17
 
18
18
  class << self
19
+ attr_accessor :config
19
20
  attr_reader :plugins
20
21
  end
21
22
 
23
+ # Loads the config, without affecting the file system.
24
+ def self.load_config
25
+ @config = Config.load
26
+ end
27
+
28
+ # Loads the config, writing a default config if it doesn't exist.
29
+ def self.load_config!
30
+ @config = Config.load!
31
+ end
32
+
22
33
  # Registers a plugin.
23
34
  #
24
35
  # @param [Plugin] plugin The plugin to register
@@ -45,12 +56,14 @@ class Repofetch
45
56
  # Raises a +Repofetch::NoPluginsError+ if no plugins are found.
46
57
  # Raises a +Repofetch::TooManyPluginsError+ if more than one plugin is found.
47
58
  #
48
- # @param [String] git An instance of +Git::Base+
59
+ # @param [Git::Base] git A repository instance.
49
60
  # @param [Array<String>] args The arguments passed to the program.
50
- # @param [Repofetch::Config] config The configuration to use.
51
61
  #
52
- # @returns [Plugin] A plugin to use.
53
- def self.get_plugin(git, args, config)
62
+ # @raise [NoPluginsError] If no plugins were selected.
63
+ # @raise [TooManyPluginsError] If more than one plugin was selected.
64
+ #
65
+ # @return [Plugin] A plugin to use.
66
+ def self.get_plugin(git, args)
54
67
  available_plugins = @plugins.filter do |plugin_class|
55
68
  plugin_class.matches_repo?(git)
56
69
  rescue NoMethodError
@@ -61,7 +74,7 @@ class Repofetch
61
74
 
62
75
  raise TooManyPluginsError if available_plugins.length > 1
63
76
 
64
- available_plugins[0].from_git(git, args, config)
77
+ available_plugins[0].from_git(git, args)
65
78
  end
66
79
 
67
80
  # Gets the name of the default remote to use.
@@ -69,9 +82,9 @@ class Repofetch
69
82
  # Will try to pick "origin", but if that is not found then it will
70
83
  # pick the first one found, or nil if there aren't any available.
71
84
  #
72
- # @param [String] path The path to the repository.
85
+ # @param [Git::Base] git The repository instance.
73
86
  #
74
- # @returns [Git::Remote]
87
+ # @return [Git::Remote]
75
88
  def self.default_remote(git)
76
89
  remotes = git.remotes
77
90
  found_remote = remotes.find { |remote| remote.name == 'origin' }
@@ -90,7 +103,7 @@ class Repofetch
90
103
  default_remote(path)&.url
91
104
  end
92
105
 
93
- # Base class for plugins.
106
+ # @abstract Subclass to create a plugin.
94
107
  class Plugin
95
108
  # Plugin intializer arguments should come from the +from_git+ or +from_args+
96
109
  # class methods.
@@ -109,7 +122,7 @@ class Repofetch
109
122
  Repofetch.replace_or_register_plugin(old, self)
110
123
  end
111
124
 
112
- # Detects that this plugin should be used. Should be overridden by subclasses.
125
+ # @abstract Detects that this plugin should be used. Should be overridden by subclasses.
113
126
  #
114
127
  # An example implementation is checking if +Repofetch.default_remote_url+ matches
115
128
  # a regular expression.
@@ -119,24 +132,22 @@ class Repofetch
119
132
  raise NoMethodError, 'matches_repo? must be overridden by the plugin subclass'
120
133
  end
121
134
 
122
- # This should use a git instance and call +Plugin.new+.
135
+ # @abstract This should use a git instance and call +Plugin.new+.
123
136
  #
124
137
  # @param [Git::Base] _git The Git repository object to use when calling +Plugin.new+.
125
138
  # @param [Array] _args The arguments to process.
126
- # @param [Config] _config The configuration loaded by the CLI.
127
139
  #
128
- # @returns [Plugin]
129
- def self.from_git(_git, _args, _config)
140
+ # @return [Plugin]
141
+ def self.from_git(_git, _args)
130
142
  raise NoMethodError, 'from_git must be overridden by the plugin subclass'
131
143
  end
132
144
 
133
- # This will receive an array of strings (e.g. +ARGV+) and call +Plugin.new+.
145
+ # @abstract This will receive an array of strings (e.g. +ARGV+) and call +Plugin.new+.
134
146
  #
135
147
  # @param [Array] _args The arguments to process.
136
- # @param [Config] _config The configuration loaded by the CLI.
137
148
  #
138
- # @returns [Plugin]
139
- def self.from_args(_args, _config)
149
+ # @return [Plugin]
150
+ def self.from_args(_args)
140
151
  raise NoMethodError, 'from_args must be overridden by the plugin subclass'
141
152
  end
142
153
 
@@ -145,7 +156,7 @@ class Repofetch
145
156
  Repofetch::DEFAULT_THEME
146
157
  end
147
158
 
148
- # The ASCII to be printed alongside the stats.
159
+ # @abstract The ASCII to be printed alongside the stats.
149
160
  #
150
161
  # This should be overridden by the plugin subclass.
151
162
  # Should be within the bounds 40x20 (width x height).
@@ -153,7 +164,7 @@ class Repofetch
153
164
  raise NoMethodError, 'ascii must be overridden by the plugin subclass'
154
165
  end
155
166
 
156
- # The header to show for the plugin.
167
+ # @abstract The header to show for the plugin.
157
168
  #
158
169
  # This should be overridden by the plugin subclass.
159
170
  # For example, "foo/bar @ GitHub".
@@ -175,9 +186,9 @@ class Repofetch
175
186
  end.join
176
187
  end
177
188
 
178
- # An array of stats that will be displayed to the right of the ASCII art.
189
+ # @abstract An array of stats that will be displayed to the right of the ASCII art.
179
190
  #
180
- # @returns [Array<Stat>]
191
+ # @return [Array<Stat>]
181
192
  def stats
182
193
  []
183
194
  end
@@ -217,7 +228,9 @@ class Repofetch
217
228
  end
218
229
 
219
230
  def to_s
220
- "#{@emoji || ''}#{@theme.nil? ? @label : @theme.format(:bold, @label)}: #{format_value}"
231
+ emoji = @emoji
232
+ emoji = nil unless Repofetch.config.nil? || Repofetch.config.emojis?
233
+ "#{emoji}#{@theme.nil? ? @label : @theme.format(:bold, @label)}: #{format_value}"
221
234
  end
222
235
 
223
236
  # Formats the value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repofetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2.pre.rc.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spenser Black
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-03 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -232,6 +232,20 @@ dependencies:
232
232
  - - "~>"
233
233
  - !ruby/object:Gem::Version
234
234
  version: '2.1'
235
+ - !ruby/object:Gem::Dependency
236
+ name: yard
237
+ requirement: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - "~>"
240
+ - !ruby/object:Gem::Version
241
+ version: 0.9.28
242
+ type: :development
243
+ prerelease: false
244
+ version_requirements: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - "~>"
247
+ - !ruby/object:Gem::Version
248
+ version: 0.9.28
235
249
  description: A plugin-based tool to fetch stats, with a GitHub stat fetcher included
236
250
  by default
237
251
  email:
@@ -249,10 +263,12 @@ files:
249
263
  - LICENSE
250
264
  - Makefile
251
265
  - README.md
266
+ - RELEASE_NOTES
252
267
  - Rakefile
253
268
  - exe/repofetch
254
269
  - lib/repofetch.rb
255
270
  - lib/repofetch/DEFAULT_CONFIG
271
+ - lib/repofetch/cli.rb
256
272
  - lib/repofetch/config.rb
257
273
  - lib/repofetch/env.rb
258
274
  - lib/repofetch/exceptions.rb
@@ -265,9 +281,11 @@ licenses:
265
281
  - MIT
266
282
  metadata:
267
283
  homepage_uri: https://github.com/spenserblack/repofetch
284
+ changelog_uri: https://github.com/spenserblack/repofetch/releases
285
+ documentation_uri: https://rubydoc.info/gems/repofetch
268
286
  source_code_uri: https://github.com/spenserblack/repofetch
269
- rubygems_mfa_required: 'true'
270
287
  github_repo: ssh://github.com/spenserblack/repofetch
288
+ rubygems_mfa_required: 'true'
271
289
  post_install_message:
272
290
  rdoc_options: []
273
291
  require_paths:
@@ -279,11 +297,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
279
297
  version: 2.7.0
280
298
  required_rubygems_version: !ruby/object:Gem::Requirement
281
299
  requirements:
282
- - - ">="
300
+ - - ">"
283
301
  - !ruby/object:Gem::Version
284
- version: '0'
302
+ version: 1.3.1
285
303
  requirements: []
286
- rubygems_version: 3.1.2
304
+ rubygems_version: 3.1.6
287
305
  signing_key:
288
306
  specification_version: 4
289
307
  summary: A plugin-based stat fetcher