GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - GSA/codeinventory: A tool to harvest project metadata from an agency's repositories

This repository was archived by the owner on Aug 6, 2021. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

60 Commits
60 Commits

Folders and files

NameName
Last commit message
Last commit date
bin
bin
 
 
exe
exe
 
 
lib
lib
 
 
spec
spec
 
 
.codeinventory.yml
.codeinventory.yml
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
Gemfile
Gemfile
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
codeinventory.gemspec
codeinventory.gemspec
 
 

Repository files navigation

CodeInventory: The People's Code

This is an experimental gem that is currently in an alpha stage. The features and interface are unstable and may change at any time.

The codeinventory gem is provides a CLI tool and a programmatic interface to harvest project metadata from an agency's repositories. The harvested metadata can be used to produce a code.json file for Code.gov. The gem includes the ability to pull project metadata from these sources:

  • JSON files
  • CSV files

More sources can be added via plugins:

  • GitHub

Table of Contents

  • Installation
  • Usage
    • CLI
    • JSON Source
    • CSV Source
    • Multiple Sources
  • Development
  • Contributing

Installation

You will need Ruby on your system in order to install and use this gem.

Add this line to your application's Gemfile:

gem 'codeinventory'

And then execute:

$ bundle

Or install it yourself as:

$ gem install codeinventory

Usage

CLI

After installing this gem, you can run codeinv, an extensible command-line interface (CLI).

$ codeinv
Commands:
  codeinv csv FILENAME    # Build an inventory from a CSV file
  codeinv help [COMMAND]  # Describe available commands or one specific command
  codeinv json FILENAME   # Build an inventory from a JSON file

To generate a code inventory from an existing CSV file, for instance:

codeinv csv my_csv_file.csv

For information on the required format of JSON and CSV input files, see JSON Source and CSV Source.

The CLI can be extended to support other sources just by installing a gem. For instance, if you install the codeinventory-github gem, you'll automatically get the github subcommand:

$ codeinv
Commands:
  codeinv csv FILENAME                                        # Build an inventory from a CSV file
  codeinv github GITHUB_ORG -a GITHUB_ACCESS_TOKEN [OPTIONS]  # Build an inventory from GitHub
  codeinv help [COMMAND]                                      # Describe available commands or one s...
  codeinv json FILENAME                                       # Build an inventory from a JSON file

JSON Source

json_source = CodeInventory::JSONFile.new(File.new("some_projects.json"))

inventory = CodeInventory::Inventory.new(json_source)
inventory.projects # Returns an array of all projects in the JSON file

When using CodeInventory::JSONFile, the source file is expected to be a JSON file in the following format:

[
  {
    "name": "Product One",
    "description": "An awesome product.",
    "license": "http://www.usa.gov/publicdomain/label/1.0/",
    "openSourceProject": 1,
    "governmentWideReuseProject": 1,
    "tags": [
      "usa"
    ],
    "contact": {
      "email": "[email protected]"
    }
  },
  {
    "name": "Product Two",
    "description": "Another awesome product.",
    "license": "http://www.usa.gov/publicdomain/label/1.0/",
    "openSourceProject": 0,
    "governmentWideReuseProject": 0,
    "tags": [
      "national-security",
      "top-secret"
    ],
    "contact": {
      "email": "[email protected]"
    }
  }
]

See the Code.gov documentation for specifics on required fields and value types.

CSV Source

csv_source = CodeInventory::CSVFile.new(File.new("more_projects.csv"))

inventory = CodeInventory::Inventory.new(csv_source)
inventory.projects # Returns an array of all projects in the CSV file

When using CodeInventory::CSVFile, the source file is expected to be a CSV file in the following format:

name,description,license,openSourceProject,governmentWideReuseProject,tags,contact.email
Product One,An awesome product.,http://www.usa.gov/publicdomain/label/1.0/,1,1,usa,[email protected]
Product Two,Another awesome product.,http://www.usa.gov/publicdomain/label/1.0/,0,0,"national-security,top-secret",[email protected]

See the Code.gov documentation for specifics on required fields and value types.

Multiple Sources

You can combine multiple sources when building an inventory.

json_source = CodeInventory::JSONFile.new(File.new("some_projects.json"))
csv_source = CodeInventory::CSVFile.new(File.new("more_projects.csv"))

inventory = CodeInventory::Inventory.new(json_source, csv_source)
inventory.projects # Returns an array of all projects in the JSON and CSV files

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/GSA/codeinventory.

About

A tool to harvest project metadata from an agency's repositories

Topics

code-gov

Resources

Readme
License
Activity
Custom properties

Stars

9 stars

Watchers

0 watching

Forks

7 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.