LanguageColours - Get colours for programming languages

I needed a way to get the GitHub colours for programming languages based on their name (as in the colours used in the bars that show how much of each language a project has) so I wrote a small library for it. You can find it at language_colours | Hex

I also wanted to learn how to structure a library to be configurable so it’s a bit overkill in that regard but should be simple to use. It has support for a fallback in case the language is not found, using the Rainbow package.

Actually currently I have an issue with the 1.0.0. It has a mix task that lets you download the colour data. This task uses httpc and thus it uses inets also. When compiling, it complains that the current project doesn’t have inets in the applications list. But it’s only used in this task so I don’t think it should be there at all. How should I get rid of this message?

7 Likes

This Elixir v1.11 release note on Compiler checks: application boundaries should help.

Thanks, I’m aware of that. My issue is that the task is not part of the library code. I.e. the task will not be present when the code is compiled to a release, it is only there for development. Thus I don’t want to add :inets to extra_applications, which would presumably affect the deployed release.

I got advice from José to use the xref trick to suppress the warning. It’ll hide any warnings about :inets, but I guess I’ll have to live with that.

Fair enough, coming from José I guess that’s all one can do… Sorry for necroing the thread.

For what it’s worth I’ve learned some good things related to configuration and dependency injection from your code. Thank you.

1 Like

There’s nothing to apologise for. :slight_smile: And thanks for your kind words.

This is my first proper library that has configuration, so don’t take it too much as gospel. :smiley: But I think it’s pretty good, though I like to use maps and structs instead of keyword lists in configuration and supervisor arguments, so that’s somewhat unusual in Elixir.

Yes, I did note of the map interface and I’m also partial to that; probably a remnant of my Ruby days.

Always good to see how others implement things even if it’s not necessarily “the done way”, can always learn something when I’m sitting in the butt-end of the world without personal mentors.

1 Like