Hi, Peter, great idea and gem!
I'd like to suggest making the functionality available on the command line as well. A trivially simple implementation would take the string into stdin and output the language code to stdout. You could have a 'whatlanguage' script in /exe containing simply, for example:
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'whatlanguage'
puts WhatLanguage.language_iso($stdin.read) || 'und'
and/or document that one could create a simple alias:
alias whatlanguage='ruby -rwhatlanguage -e '\''puts WhatLanguage.language_iso($stdin.read) || "und"'\'
or, if you prefer, a shell function:
whatlanguage(){ ruby -rwhatlanguage -e 'puts WhatLanguage.language_iso($stdin.read) || "und"'; }
...and then call any as in:
$ whatlanguage < README.md
en
For the executable script, you'd also want to specify this in the gemspec:
Hi, Peter, great idea and gem!
I'd like to suggest making the functionality available on the command line as well. A trivially simple implementation would take the string into stdin and output the language code to stdout. You could have a 'whatlanguage' script in /exe containing simply, for example:
and/or document that one could create a simple alias:
or, if you prefer, a shell function:
...and then call any as in:
$ whatlanguage < README.md enFor the executable script, you'd also want to specify this in the gemspec: