No release in over 3 years
Low commit activity in last 3 years
Field guide for programming languages, based on the knowledge imparted by github-linguist
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 12.3.3
~> 3.0
~> 0.21.2
 Project Readme

Linguist's Field Guide 📖

Gem Version Ruby codecov

Field guide for programming languages, based on the knowledge imparted by github-linguist.

Background

This contains data derived from GitHub's linguist Gem, which is in turn used by GitHub to detect languages of repositories and files.

Many consumers don't need all of linguist's features or dependencies, and in many cases the list is sufficient to aid in interoperating with GitHub and other systems which use or rely on linguist.

The Linguist's Field Guide, therefore, provides the language information known to linguist, without requiring all of linguist's functionality. Just the information, not necessarily the skills!

Installation

gem install linguists_field_guide

Usage

linguists_field_guide provides an API modeled after linguist's own.

LinguistsFieldGuide::Language provides a subset of Linguist::Language;

  • An Array of all Languages can be retrieved by calling LinguistsFieldGuide::Language.all
  • A specific Language can be found by using LinguistsFieldGuide::Language.find_by_name
  • Other Linguist::Language class methods (find_by_alias, find_by_extension, find_by_filename, etc.) are not currently provided.
  • Language instances contain readers for properties included in the version of Linguist it was built against, with these exceptions:
    • Derived methods (default_alias, escaped_name, hash, etc.) are not currently provided.

Example

require 'linguists_field_guide'

languages_to_check = ["Rust", "Ruby", "JavaScript", "Bash"]

languages_to_check.each do |language_name|
  if LinguistsFieldGuide::Language.find_by_name(language_name)
    puts "⭕️ #{language_name} is a known language name"
  else
    puts "❌ #{language_name} isn't a known language name!"
  end
end

Console output:

⭕️ Rust is a known language name
⭕️ Ruby is a known language name
⭕️ JavaScript is a known language name
❌ Bash isn't a known language name!

Development

Requirements

  • Ruby
  • Bundler

Initial setup

To install all the Ruby and Javascript dependencies, you can run:

bundle install

To update the Ruby source files based on the emoji-regex library:

rake regenerate

Specs

A spec suite is provided, which can be run as:

rake spec

Creating a release

  1. Update the version in linguists_field_guide.gemspec
  2. rake release