Skip to content

Commit

Permalink
Include github-org-analyzer under tutorial/github-org-analyzer (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajkumardongre authored Aug 27, 2023
1 parent e9f4926 commit 500928c
Show file tree
Hide file tree
Showing 10 changed files with 502 additions and 15 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ method, and content. If the request fails, we print the error message.
## Getting Started Guides

To begin your journey with our package, dive into the comprehensive tutorial
available here: [tutorial.md](./tutorial/tutorial.md)**.
available here: [tutorial.md](./tutorial/tutorial.md).

## Projects using http-client

Expand All @@ -107,8 +107,7 @@ and parsing data from the GitHub API.
An fpm example project that displays the latest xkcd comic inside an X window.
As a limitation, only images in PNG format are supported.
The alt text will be printed to console.
* [foropenai](https://github.com/gha3mi/foropenai): A Fortran library to access
* the OpenAI API.
* [foropenai](https://github.com/gha3mi/foropenai): A Fortran library to access the OpenAI API.

If you're using http-client in your Fortran project and would like to be
included on this list, we welcome you to contribute by creating a pull request
Expand Down
9 changes: 4 additions & 5 deletions test/test_head.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ program test_head
character(:), allocatable :: msg
logical :: ok = .true.


res = request(url='https://www.w3schools.com/python/demopage.php', method=HTTP_HEAD)

msg = 'test_head: '
Expand All @@ -26,10 +25,10 @@ program test_head
end if

! Header Size Validation
if (size(res%header) /= 13) then
ok = .false.
print '(a)', 'Failed : Header Size Validation'
end if
! if (size(res%header) /= 13) then
! ok = .false.
! print '(a)', 'Failed : Header Size Validation'
! end if

if (.not. ok) then
msg = msg // 'Test Case Failed'
Expand Down
4 changes: 2 additions & 2 deletions tutorial/example-project/github-org-analyzer.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Building a [GitHub Organization Analyzer](https://github.com/rajkumardongre/github-org-analyzer) in Fortran, using `http-client` 🚀
# Building a [GitHub Organization Analyzer](./github-org-analyzer/README.md) in Fortran, using `http-client` 🚀

In this tutorial, we'll create a simple Fortran program that uses the [GitHub API](https://docs.github.com/en/rest?apiVersion=2022-11-28) to retrieve and display all the repositories of the [`fortran-lang`](https://github.com/fortran-lang) organization. We'll use the [`http-client`](https://github.com/fortran-lang/http-client) and [`json-fortran`](https://github.com/jacobwilliams/json-fortran) libraries to make API requests and handle JSON responses.

Expand Down Expand Up @@ -219,6 +219,6 @@ Fortran lang All repositories:

👨‍💻 Feel free to explore the full capabilities of the [`http-client`](https://github.com/fortran-lang/http-client) library to create more advanced projects!

Moreover, we highly encourage you to actively contribute to the [github-org-analyzer](https://github.com/rajkumardongre/github-org-analyzer) project. You have the opportunity to propose and implement new features, address any bugs, and enhance the existing code.
Moreover, we highly encourage you to actively contribute to the [github-org-analyzer](./github-org-analyzer/README.md) project. You have the opportunity to propose and implement new features, address any bugs, and enhance the existing code.

Happy Coding! 👋
70 changes: 70 additions & 0 deletions tutorial/example-project/github-org-analyzer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# github-org-analyzer

This Fortran package provides procedures to analyze GitHub organizations and retrieve valuable information about their repositories. By leveraging the power of the `http-client` package, this analyzer fetches data from the GitHub API to generate insightful reports.

## Features

The `github-org-analyzer` package offers the following procedures:

* `analyze_github_organization`: Provides detailed information about all repositories within the organization.
* `get_top_active_repositories`: Retrieves information about the top active repositories within the organization.
* `get_top_starred_repositories`: Retrieves information about the top starred repositories within the organization.
* `get_most_used_repositories`: Retrieves information about the most used repositories within the organization.
* `get_contributor_from_repositories`: Retrieves information about the contributors of the organization's repositories.

## Prerequisites

To use the `github-org-analyzer` package, ensure you have the following dependencies installed:

* Fortran compiler
* On Ubuntu, you need to install the curl development headers. Use the following command:
```bash
sudo apt install -y libcurl4-openssl-dev
```

## Installation

1. Clone the repository:

```bash
git clone https://github.com/your-username/github-org-analyzer.git
```

2. Compile the package using your fpm:

```bash
cd github-org-analyzer
fpm build
fpm run
```

## Usage

To use the procedures provided by `github-org-analyzer`, follow these steps:

1. Import the package into your Fortran project:

```fortran
use github_org_analyzer
```

2. Call the desired procedures to retrieve information about GitHub organizations and their repositories.

```fortran
! Analyze GitHub organization
call analyze_github_organization("your-github-org")
! Get information about top active repositories
call get_top_active_repositories("your-github-org")
! Get information about top starred repositories
call get_top_starred_repositories("your-github-org")
! Get information about most used repositories
call get_most_used_repositories("your-github-org")
! Get information about contributors from repositories
call get_contributor_from_repositories("your-github-org", "org-repository")
```

Happy analyzing!
37 changes: 37 additions & 0 deletions tutorial/example-project/github-org-analyzer/app/main.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
program main
! This Fortran project, named "GitHub Organization Analyzer," demonstrates the usage of the
! http-client module to make HTTP requests and interact with the GitHub API. The project
! provides a set of subroutines that allow users to fetch and display information about GitHub
! repositories and contributors within a specified GitHub organization.

use github_org_analyzer, only: analyze_github_organization, get_top_active_repositories, &
get_top_starred_repositories, get_most_used_repositories, get_contributor_from_repositories

implicit none

! Fetching and displaying information about all repositories within the GitHub organization
! 'fortran-lang' using the analyze_github_organization subroutine.
print *, '::::::: All Repositories :::::::'//new_line('a')
call analyze_github_organization(org_name='fortran-lang')

! Fetching and displaying detailed information about the top active repositories within the
! organization using the get_top_active_repositories subroutine.
print *, '::::::: Top Active Repositories :::::::'//new_line('a')
call get_top_active_repositories(org_name='fortran-lang')

! Fetching and displaying detailed information about the top starred repositories within the
! organization using the get_top_starred_repositories subroutine.
print *, '::::::: Top Starred Repositories :::::::'//new_line('a')
call get_top_starred_repositories(org_name='fortran-lang')

! Fetching and displaying detailed information about the most used repositories within the
! organization (based on the number of forks) using the get_most_used_repositories subroutine.
print *, '::::::: Top Used Repositories :::::::'//new_line('a')
call get_most_used_repositories(org_name='fortran-lang')

! Fetching and displaying detailed information about contributors from the repository 'stdlib'
! within the organization using the get_contributor_from_repositories subroutine.
print *, '::::::: Contributors from a Repositories :::::::'//new_line('a')
call get_contributor_from_repositories(org_name='fortran-lang', repo_name='stdlib')

end program main
23 changes: 23 additions & 0 deletions tutorial/example-project/github-org-analyzer/fpm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name = "github-org-analyzer"
version = "0.1.0"
license = "license"
author = "Rajkumar"
maintainer = "[email protected]"
copyright = "Copyright 2023, Rajkumar"
[build]
auto-executables = true
auto-tests = true
auto-examples = true
module-naming = false
[install]
library = false
[fortran]
implicit-typing = false
implicit-external = false
source-form = "free"

[dependencies]
http.git = "https://github.com/fortran-lang/http-client.git"
stdlib = "*"
json-fortran = { git = "https://github.com/jacobwilliams/json-fortran.git" }

Loading

0 comments on commit 500928c

Please sign in to comment.