gitmarshal 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +118 -0
- data/bin/console +15 -0
- data/bin/gitmarshal +5 -0
- data/bin/setup +8 -0
- data/gitmarshal.gemspec +62 -0
- data/lib/gitmarshal/base_fetcher.rb +25 -0
- data/lib/gitmarshal/cli.rb +115 -0
- data/lib/gitmarshal/github_fetcher.rb +92 -0
- data/lib/gitmarshal/metric_fetcher.rb +48 -0
- data/lib/gitmarshal/version.rb +5 -0
- data/lib/gitmarshal.rb +9 -0
- metadata +191 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 351dad1ba766260604fdb167d697a209b9d2b4ad45782f7bf3b738520541ce31
|
4
|
+
data.tar.gz: 1980015eef8a3cc130ec2eb6b20d56736b78c8a2ab5e3e85c01281de239a205c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 594847b1f1427ec8bdc359475090cb71faa23e27224f9032c16341c9bb6d58b6b66ee39b278226f78cc9844a090875f04c7de700792d1759425edd55d1aba6de
|
7
|
+
data.tar.gz: 50404ba54d11d352929f646c40e77f19eaf2af86a399bf4bf7d0b1ba3c74306fb07b6617b1ff5bb8e7d20c39903f9ad0966f6f25cd1b764bab37c59ce5f43614
|
data/README.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# GitMarshal
|
2
|
+
[](https://opensource.org/licenses/MIT) [](https://codeclimate.com/github/nagstler/gitmarshal/maintainability)
|
3
|
+
|
4
|
+
GitMarshal is a command-line interface (CLI) to extract and display various statistics about GitHub repositories. The metrics it retrieves include the number of commits, pull requests, issues, stars, and contributors.
|
5
|
+
|
6
|
+
Whether you're a developer interested in the activity of a repository or a manager tracking the progress of your project, GitMarshal provides an easy way to fetch this data directly from your command line.
|
7
|
+
|
8
|
+
## Features
|
9
|
+
|
10
|
+
- Fetch and display a summary of your GitHub repositories.
|
11
|
+
- Fetch and display detailed metrics for a specific repository, including number of commits, pull requests, issues, stars, and contributors.
|
12
|
+
- Easy-to-use command-line interface.
|
13
|
+
- Configurable through environment variables.
|
14
|
+
- Available as a Ruby gem for easy installation.
|
15
|
+
|
16
|
+
|
17
|
+
## Table of Contents
|
18
|
+
- [Prerequisites](#prerequisites)
|
19
|
+
- [Installation](#installation)
|
20
|
+
- [Configuration](#configuration)
|
21
|
+
- [Usage](#usage)
|
22
|
+
- [Development](#development)
|
23
|
+
- [Contributing](#contributing)
|
24
|
+
- [License](#license)
|
25
|
+
|
26
|
+
## Prerequisites
|
27
|
+
|
28
|
+
Before installing GitMarshal, make sure you have Ruby installed in your system. If you're unsure, you can check this by running the following command in your terminal:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
ruby -v
|
32
|
+
```
|
33
|
+
|
34
|
+
If Ruby is installed, you should see its version. GitMarshal requires Ruby version 2.5 or later.
|
35
|
+
|
36
|
+
In addition to Ruby, you will need a GitHub access token to use GitMarshal. Here's how you can generate one:
|
37
|
+
1. Visit the following URL: [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new)
|
38
|
+
2. Enter a Note (this can be anything, e.g., "For GitMarshal").
|
39
|
+
3. Under "Select scopes", check the "repo" option.
|
40
|
+
4. Click on "Generate token" at the bottom.
|
41
|
+
|
42
|
+
Remember to save the generated token as you will need it during the configuration step.
|
43
|
+
|
44
|
+
## Installation
|
45
|
+
|
46
|
+
GitMarshal can be installed directly as a Ruby gem. To do so, simply run the following command in your terminal:
|
47
|
+
|
48
|
+
```bash
|
49
|
+
gem install gitmarshal
|
50
|
+
```
|
51
|
+
This command will download and install the GitMarshal gem onto your system.
|
52
|
+
|
53
|
+
## Configuration
|
54
|
+
|
55
|
+
To use GitMarshal, an environment variable with your GitHub access token needs to be set up. You can do this by adding the following line to your shell profile file (such as `.bashrc`, `.bash_profile`, or `.zshrc`):
|
56
|
+
|
57
|
+
```bash
|
58
|
+
export GITHUB_TOKEN=your_github_token_here
|
59
|
+
```
|
60
|
+
|
61
|
+
Be sure to replace `your_github_token_here` with the token you generated in the Prerequisites step.
|
62
|
+
|
63
|
+
## Usage
|
64
|
+
Once installed and configured, GitMarshal can be used directly from the command-line as follows:
|
65
|
+
|
66
|
+
### List All Repositories
|
67
|
+
|
68
|
+
To fetch and display a summary of all your GitHub repositories, run:
|
69
|
+
|
70
|
+
```bash
|
71
|
+
gitmarshal
|
72
|
+
```
|
73
|
+
|
74
|
+
This will provide you with a comprehensive list of your repositories and will show the number of issues, stars, and forks for each repository.
|
75
|
+
|
76
|
+
### Fetch Metrics for a Specific Repository
|
77
|
+
|
78
|
+
To fetch and display metrics for a specific repository, use:
|
79
|
+
|
80
|
+
```bash
|
81
|
+
gitmarshal repo-name
|
82
|
+
```
|
83
|
+
|
84
|
+
Replace `repo_name` with the name of the repository for which you wish to fetch metrics.
|
85
|
+
|
86
|
+
## Development
|
87
|
+
|
88
|
+
If you'd like to contribute to the development of GitMarshal, first clone the repository and install the dependencies:
|
89
|
+
|
90
|
+
```bash
|
91
|
+
git clone https://github.com/nagstler/gitmarshal.git
|
92
|
+
cd gitmarshal
|
93
|
+
bundle install
|
94
|
+
```
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
You can then run the tests with:
|
99
|
+
|
100
|
+
```bash
|
101
|
+
rake spec
|
102
|
+
```
|
103
|
+
|
104
|
+
For a more interactive development experience, start a console with:
|
105
|
+
|
106
|
+
```bash
|
107
|
+
bin/console
|
108
|
+
```
|
109
|
+
|
110
|
+
## Contributing
|
111
|
+
|
112
|
+
Your contributions to further improve GitMarshal are most welcome. Whether it's reporting a bug or proposing a new feature, you can help enhance this tool. Feel free to create bug reports and pull requests on our GitHub page at [https://github.com/nagstler/gitmarshal](https://github.com/nagstler/gitmarshal) .
|
113
|
+
|
114
|
+
We aim to maintain a welcoming and inclusive environment for collaboration, and all contributors are expected to adhere to the [Contributor Covenant](https://www.contributor-covenant.org/) code of conduct.
|
115
|
+
|
116
|
+
## License
|
117
|
+
|
118
|
+
GitMarshal is open-source and available under the terms of the [MIT License](https://opensource.org/licenses/MIT) .
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "gitmarshal"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/gitmarshal
ADDED
data/bin/setup
ADDED
data/gitmarshal.gemspec
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/gitmarshal/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gitmarshal"
|
7
|
+
spec.version = Gitmarshal::VERSION
|
8
|
+
spec.authors = ["Nagendra Dhanakeerthi"]
|
9
|
+
spec.email = ["nagendra.dhanakeerthi@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Command-line tool for fetching and displaying GitHub repository metrics"
|
12
|
+
spec.description = <<-DESC
|
13
|
+
GitMarshal is a command-line tool that allows developers to fetch and display various metrics
|
14
|
+
about GitHub repositories. It provides insights into issues, stargazers, forks, commits,
|
15
|
+
pull requests, and more.
|
16
|
+
DESC
|
17
|
+
spec.homepage = "https://github.com/nagstler/gitmarshal"
|
18
|
+
spec.license = "MIT"
|
19
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
20
|
+
|
21
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/nagstler/gitmarshal"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/nagstler/gitmarshal/blob/main/CHANGELOG.md"
|
25
|
+
|
26
|
+
spec.files = Dir.glob("{bin,lib}/**/*", File::FNM_DOTMATCH) + ["gitmarshal.gemspec", "README.md"]
|
27
|
+
spec.bindir = "bin"
|
28
|
+
spec.executables = ["gitmarshal"]
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency "json", "~> 2.5"
|
32
|
+
spec.add_dependency "thor", "~> 1.1"
|
33
|
+
spec.add_dependency "terminal-table", "~> 3.0.0"
|
34
|
+
spec.add_dependency 'colorize', '~> 0.8'
|
35
|
+
spec.add_dependency 'octokit', '~> 4.0'
|
36
|
+
spec.add_dependency 'faraday-retry', '~> 2.0'
|
37
|
+
|
38
|
+
# Development Dependencies
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.10"
|
40
|
+
spec.add_development_dependency "rubocop", "~> 1.22"
|
41
|
+
|
42
|
+
spec.post_install_message = <<-MSG
|
43
|
+
|
44
|
+
#################################################################
|
45
|
+
############## GITMARSHAL ##################
|
46
|
+
#################################################################
|
47
|
+
|
48
|
+
Thank you for installing GitMarshal!
|
49
|
+
|
50
|
+
GitMarshal is a command-line tool that allows developers to fetch and display various metrics about GitHub repositories.
|
51
|
+
|
52
|
+
In order to use GitMarshal, you need to set up your GitHub access token. Please follow the instructions provided in the README at:
|
53
|
+
|
54
|
+
https://github.com/nagstler/gitmarshal#configuration
|
55
|
+
|
56
|
+
Enjoy using GitMarshal!
|
57
|
+
|
58
|
+
#################################################################
|
59
|
+
|
60
|
+
MSG
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
class BaseFetcher
|
5
|
+
GITHUB_API_BASE_URL = "https://api.github.com"
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def execute_http_request(req)
|
10
|
+
Net::HTTP.start(req.uri.hostname, req.uri.port, :use_ssl => req.uri.scheme == 'https') do |http|
|
11
|
+
http.request(req)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_request(uri)
|
16
|
+
Net::HTTP::Get.new(uri,
|
17
|
+
"Content-Type" => "application/json",
|
18
|
+
"Authorization" => "Bearer #{ENV['GITHUB_TOKEN']}"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse_response(response)
|
23
|
+
JSON.parse(response.body)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'terminal-table'
|
3
|
+
require 'colorize'
|
4
|
+
require_relative 'github_fetcher'
|
5
|
+
|
6
|
+
module GitMarshal
|
7
|
+
class CLI < Thor
|
8
|
+
class_option :help, type: :boolean, aliases: '-h', desc: 'Display usage information'
|
9
|
+
|
10
|
+
desc "repos", "Prints a summary of the authenticated user's GitHub repositories"
|
11
|
+
def repos
|
12
|
+
begin
|
13
|
+
fetcher = GithubFetcher.new
|
14
|
+
user = fetcher.fetch_user
|
15
|
+
repos = fetcher.fetch_repos
|
16
|
+
|
17
|
+
puts "GitHub Repositories for #{user}".colorize(:blue).bold
|
18
|
+
|
19
|
+
rows = repos.map do |repo|
|
20
|
+
[
|
21
|
+
repo['name'],
|
22
|
+
repo['issues'],
|
23
|
+
repo['stargazers'],
|
24
|
+
repo['forks']
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
table = Terminal::Table.new :title => "Repositories".colorize(:green).bold,
|
29
|
+
:headings => ['Name', 'Issues', 'Stargazers', 'Forks'].map { |i| i.colorize(:magenta).bold },
|
30
|
+
:rows => rows
|
31
|
+
|
32
|
+
table.style = { :border_x => "=", :border_i => "x", :alignment => :center }
|
33
|
+
puts table
|
34
|
+
rescue StandardError => e
|
35
|
+
puts "An error occurred: #{e.message}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def help(*)
|
41
|
+
puts "You can either call ./bin/gitmarshal to list all repositories or ./bin/gitmarshal repo-name to show the metrics of the given repository."
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def metrics(repo_name)
|
47
|
+
fetcher = GithubFetcher.new
|
48
|
+
user = fetcher.fetch_user
|
49
|
+
|
50
|
+
repo = fetcher.fetch_repo_metrics(user, repo_name)
|
51
|
+
|
52
|
+
# Print repository name and other details as introduction
|
53
|
+
puts "GitHub Repository: #{repo['name']}".colorize(:blue).bold
|
54
|
+
puts "Description: #{repo['description']}"
|
55
|
+
puts "Default Branch: #{repo['default_branch']}"
|
56
|
+
puts "Last Updated At: #{repo['last_updated_at']}"
|
57
|
+
|
58
|
+
puts "x======================================x"
|
59
|
+
|
60
|
+
# Display latest commit
|
61
|
+
latest_commit = fetcher.fetch_latest_commit(user, repo_name)
|
62
|
+
if latest_commit
|
63
|
+
puts "Latest Commit:".colorize(:blue).bold
|
64
|
+
puts "Commit Date: #{latest_commit['commit']['committer']['date']}"
|
65
|
+
puts "Commit Message: #{latest_commit['commit']['message']}"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Display repository metrics in a table
|
69
|
+
rows = [
|
70
|
+
['Total Commits', repo['commits_count']],
|
71
|
+
['Pull Requests', repo['pull_requests_count']],
|
72
|
+
['Forks', repo['forks_count']],
|
73
|
+
['Watchers', repo['watchers_count']],
|
74
|
+
['Issues', repo['issues_count']],
|
75
|
+
['Open Issues', repo['open_issues_count']],
|
76
|
+
['Closed Issues', repo['closed_issues_count']],
|
77
|
+
['Open Pull Requests', repo['open_pull_requests_count']],
|
78
|
+
['Closed Pull Requests', repo['closed_pull_requests_count']],
|
79
|
+
['Contributors', repo['contributors_count']],
|
80
|
+
['Stargazers', repo['stargazers_count']]
|
81
|
+
]
|
82
|
+
|
83
|
+
table = Terminal::Table.new :title => "Repository Metrics".colorize(:blue).bold, :headings => ['Metric', 'Count'].map { |i| i.colorize(:magenta).bold }, :rows => rows
|
84
|
+
table.style = { :border_x => "=", :border_i => "x", :alignment => :center }
|
85
|
+
puts table
|
86
|
+
|
87
|
+
# # Display today's repository metrics in a table
|
88
|
+
# today_rows = [
|
89
|
+
# ['Today\'s Total Commits', fetcher.fetch_today_commits_count(user, repo_name)],
|
90
|
+
# ['Today\'s Pull Requests', fetcher.fetch_today_pull_requests_count(user, repo_name)],
|
91
|
+
# ['Today\'s Closed Pull Requests', fetcher.fetch_today_closed_pull_requests_count(user, repo_name)],
|
92
|
+
# ['Today\'s Open Pull Requests', fetcher.fetch_today_open_pull_requests_count(user, repo_name)],
|
93
|
+
# ['Today\'s Issues', fetcher.fetch_today_issues_count(user, repo_name)],
|
94
|
+
# ['Today\'s Closed Issues', fetcher.fetch_today_closed_issues_count(user, repo_name)],
|
95
|
+
# ['Today\'s Open Issues', fetcher.fetch_today_open_issues_count(user, repo_name)]
|
96
|
+
# ]
|
97
|
+
|
98
|
+
# today_table = Terminal::Table.new :title => "Today's Repository Metrics".colorize(:green).bold, :headings => ['Metric', 'Count'].map { |i| i.colorize(:magenta).bold }, :rows => today_rows
|
99
|
+
# today_table.style = { :border_x => "=", :border_i => "x", :alignment => :center }
|
100
|
+
# puts today_table
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
def method_missing(method, *_args, &_block)
|
106
|
+
if method =~ /[-a-zA-Z0-9_.]+/
|
107
|
+
metrics(method.to_s)
|
108
|
+
else
|
109
|
+
super
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
default_command :repos
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require_relative 'metric_fetcher'
|
2
|
+
require 'octokit'
|
3
|
+
|
4
|
+
class GithubFetcher
|
5
|
+
def initialize
|
6
|
+
Octokit.configure do |config|
|
7
|
+
config.access_token = ENV['GITHUB_TOKEN']
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch_user
|
12
|
+
Octokit.user.login
|
13
|
+
end
|
14
|
+
|
15
|
+
def fetch_repos
|
16
|
+
Octokit.repositories.map do |repo|
|
17
|
+
{
|
18
|
+
'name' => repo.name,
|
19
|
+
'issues' => repo.open_issues_count,
|
20
|
+
'stargazers' => repo.stargazers_count,
|
21
|
+
'forks' => repo.forks_count
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_repo_metrics(user, repo_name)
|
27
|
+
repo = Octokit.repository("#{user}/#{repo_name}")
|
28
|
+
{
|
29
|
+
'name' => repo.name,
|
30
|
+
'description' => repo.description,
|
31
|
+
'default_branch' => repo.default_branch,
|
32
|
+
'last_updated_at' => repo.updated_at,
|
33
|
+
'watchers_count' => repo.watchers_count,
|
34
|
+
'forks_count' => repo.forks_count,
|
35
|
+
'open_issues_count' => repo.open_issues_count,
|
36
|
+
'commits_count' => Octokit.commits("#{user}/#{repo_name}").count,
|
37
|
+
'pull_requests_count' => Octokit.pull_requests("#{user}/#{repo_name}").count,
|
38
|
+
'closed_pull_requests_count' => Octokit.pull_requests("#{user}/#{repo_name}", state: 'closed').count,
|
39
|
+
'open_pull_requests_count' => Octokit.pull_requests("#{user}/#{repo_name}", state: 'open').count,
|
40
|
+
'issues_count' => Octokit.issues("#{user}/#{repo_name}").count,
|
41
|
+
'closed_issues_count' => Octokit.issues("#{user}/#{repo_name}", state: 'closed').count,
|
42
|
+
'stargazers_count' => repo.stargazers_count,
|
43
|
+
'contributors_count' => Octokit.contributors("#{user}/#{repo_name}").count
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def fetch_latest_commit(user, repo_name)
|
48
|
+
Octokit.commits("#{user}/#{repo_name}").first
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch_today_commits_count(user, repo_name)
|
52
|
+
Octokit.commits("#{user}/#{repo_name}").count do |commit|
|
53
|
+
commit.commit.committer.date.to_date == Date.today
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def fetch_today_pull_requests_count(user, repo_name)
|
58
|
+
Octokit.pull_requests("#{user}/#{repo_name}").count do |pr|
|
59
|
+
pr.created_at.to_date == Date.today
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def fetch_today_closed_pull_requests_count(user, repo_name)
|
64
|
+
Octokit.pull_requests("#{user}/#{repo_name}", state: 'closed').count do |pr|
|
65
|
+
pr.closed_at.to_date == Date.today
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def fetch_today_open_pull_requests_count(user, repo_name)
|
70
|
+
Octokit.pull_requests("#{user}/#{repo_name}", state: 'open').count do |pr|
|
71
|
+
pr.created_at.to_date == Date.today
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def fetch_today_issues_count(user, repo_name)
|
76
|
+
Octokit.issues("#{user}/#{repo_name}").count do |issue|
|
77
|
+
issue.created_at.to_date == Date.today
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def fetch_today_closed_issues_count(user, repo_name)
|
82
|
+
Octokit.issues("#{user}/#{repo_name}", state: 'closed').count do |issue|
|
83
|
+
issue.closed_at.to_date == Date.today
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def fetch_today_open_issues_count(user, repo_name)
|
88
|
+
Octokit.issues("#{user}/#{repo_name}", state: 'open').count do |issue|
|
89
|
+
issue.created_at.to_date == Date.today
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'base_fetcher'
|
2
|
+
|
3
|
+
class MetricFetcher < BaseFetcher
|
4
|
+
def fetch_today_commits_count(owner, repo_name)
|
5
|
+
today = Date.today.strftime("%Y-%m-%d")
|
6
|
+
uri = URI("#{GITHUB_API_BASE_URL}/repos/#{owner}/#{repo_name}/commits?since=#{today}T00:00:00Z")
|
7
|
+
|
8
|
+
req = create_request(uri)
|
9
|
+
|
10
|
+
response = execute_http_request(req)
|
11
|
+
commits_data = parse_response(response)
|
12
|
+
|
13
|
+
commits_data.size
|
14
|
+
end
|
15
|
+
|
16
|
+
def fetch_pr_count(owner, repo_name)
|
17
|
+
uri = URI("#{GITHUB_API_BASE_URL}/repos/#{owner}/#{repo_name}/pulls?state=all")
|
18
|
+
|
19
|
+
req = create_request(uri)
|
20
|
+
|
21
|
+
response = execute_http_request(req)
|
22
|
+
pr_data = parse_response(response)
|
23
|
+
|
24
|
+
pr_data.size
|
25
|
+
end
|
26
|
+
|
27
|
+
def fetch_issue_count(owner, repo_name)
|
28
|
+
uri = URI("#{GITHUB_API_BASE_URL}/repos/#{owner}/#{repo_name}/issues?state=all")
|
29
|
+
|
30
|
+
req = create_request(uri)
|
31
|
+
|
32
|
+
response = execute_http_request(req)
|
33
|
+
issues_data = parse_response(response)
|
34
|
+
|
35
|
+
issues_data.size
|
36
|
+
end
|
37
|
+
|
38
|
+
def fetch_star_count(owner, repo_name)
|
39
|
+
uri = URI("#{GITHUB_API_BASE_URL}/repos/#{owner}/#{repo_name}")
|
40
|
+
|
41
|
+
req = create_request(uri)
|
42
|
+
|
43
|
+
response = execute_http_request(req)
|
44
|
+
star_data = parse_response(response)
|
45
|
+
|
46
|
+
star_data['stargazers_count']
|
47
|
+
end
|
48
|
+
end
|
data/lib/gitmarshal.rb
ADDED
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitmarshal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nagendra Dhanakeerthi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-07-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: terminal-table
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: octokit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday-retry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.10'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.10'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.22'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.22'
|
125
|
+
description: |2
|
126
|
+
GitMarshal is a command-line tool that allows developers to fetch and display various metrics
|
127
|
+
about GitHub repositories. It provides insights into issues, stargazers, forks, commits,
|
128
|
+
pull requests, and more.
|
129
|
+
email:
|
130
|
+
- nagendra.dhanakeerthi@gmail.com
|
131
|
+
executables:
|
132
|
+
- gitmarshal
|
133
|
+
extensions: []
|
134
|
+
extra_rdoc_files: []
|
135
|
+
files:
|
136
|
+
- README.md
|
137
|
+
- bin/console
|
138
|
+
- bin/gitmarshal
|
139
|
+
- bin/setup
|
140
|
+
- gitmarshal.gemspec
|
141
|
+
- lib/gitmarshal.rb
|
142
|
+
- lib/gitmarshal/base_fetcher.rb
|
143
|
+
- lib/gitmarshal/cli.rb
|
144
|
+
- lib/gitmarshal/github_fetcher.rb
|
145
|
+
- lib/gitmarshal/metric_fetcher.rb
|
146
|
+
- lib/gitmarshal/version.rb
|
147
|
+
homepage: https://github.com/nagstler/gitmarshal
|
148
|
+
licenses:
|
149
|
+
- MIT
|
150
|
+
metadata:
|
151
|
+
allowed_push_host: https://rubygems.org
|
152
|
+
homepage_uri: https://github.com/nagstler/gitmarshal
|
153
|
+
source_code_uri: https://github.com/nagstler/gitmarshal
|
154
|
+
changelog_uri: https://github.com/nagstler/gitmarshal/blob/main/CHANGELOG.md
|
155
|
+
post_install_message: |2+
|
156
|
+
|
157
|
+
#################################################################
|
158
|
+
############## GITMARSHAL ##################
|
159
|
+
#################################################################
|
160
|
+
|
161
|
+
Thank you for installing GitMarshal!
|
162
|
+
|
163
|
+
GitMarshal is a command-line tool that allows developers to fetch and display various metrics about GitHub repositories.
|
164
|
+
|
165
|
+
In order to use GitMarshal, you need to set up your GitHub access token. Please follow the instructions provided in the README at:
|
166
|
+
|
167
|
+
https://github.com/nagstler/gitmarshal#configuration
|
168
|
+
|
169
|
+
Enjoy using GitMarshal!
|
170
|
+
|
171
|
+
#################################################################
|
172
|
+
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 2.6.0
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubygems_version: 3.0.3.1
|
188
|
+
signing_key:
|
189
|
+
specification_version: 4
|
190
|
+
summary: Command-line tool for fetching and displaying GitHub repository metrics
|
191
|
+
test_files: []
|