linguist.cr v0.2.2
linguist.cr
Github's linguist but in crystal.
Linguist will use different ways to find what type of programming language every file is, which can be used for stats or for highlights.
We only have filename, extension name and classifier mapping now but support languages.yml-format and samples format from Github's linguist. Hopefully soon we will add the rest, like Heuristics and shebang filtering support.
We can not promise that the loaded data in ./data
is up to date. So if you want to be sure, let's train it again with overwrite set to true
.
Installation
-
Add the dependency to your
shard.yml
:dependencies: linguist.cr: github: microgit-com/linguist.cr
-
Run
shards install
Usage
require "linguist"
Set path to the languages.yml if it is not working like this:
Linguist.configure do |settings|
settings.path = "./config/linguist/languages.yml"
end
The languages.yml can be found in the git repo of this or a more up to date one on github's linguist repo at https://github.com/github/linguist
Using repository
repo = Git::Repository.open("./")
linguist = Linguist::Linguist.new
linguist.with_repo(repo, repo.head.target_id)
logger = Logger.new(STDOUT)
langs = linguist.languages
logger.info langs
Development
We have this todo:
- Repository blob support
- Classifier
- Filename-finder
- Extension-finder
- Heuristics support
- Shebang filter support
- simple file text check without repository.
Contributing
- Fork it (https://github.com/microgit-com/linguist.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Håkan Nylén - creator and maintainer
linguist.cr
- 8
- 1
- 0
- 1
- 4
- over 4 years ago
- February 15, 2020
MIT License
Wed, 06 Nov 2024 22:37:12 GMT