Linguist's Field Guide 📖
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_guideUsage
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::Languageclass methods (find_by_alias,find_by_extension,find_by_filename, etc.) are not currently provided. -
Languageinstances contain readers for properties included in the version ofLinguistit was built against, with these exceptions:- Derived methods (
default_alias,escaped_name,hash, etc.) are not currently provided.
- Derived methods (
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
endConsole 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 installTo update the Ruby source files based on the emoji-regex library:
rake regenerateSpecs
A spec suite is provided, which can be run as:
rake specCreating a release
- Update the version in linguists_field_guide.gemspec
rake release