-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace File.read
used in package
#4
Comments
Hi @SimonLab, As for renaming The update in #3 the change is "breaking" so technically, |
Package published to https://hex.pm/packages/statuses/1.1.0 📦 |
The change from |
** (ArgumentError) errors were found at the given arguments:
* 1st argument: not an atom
:erlang.atom_to_binary("done", :utf8)
priv/repo/seeds.exs:18: anonymous fn/1 in :elixir_compiler_1.__FILE__/1
(elixir 1.13.4) lib/enum.ex:937: Enum."-each/2-lists^foreach/1-0-"/2
priv/repo/seeds.exs:16: (file) Line 29 in b3c5950
All other statuses are |
Remove |
Having the |
The obvious disadvantage (IMO) of having the data embedded in the code: Lines 11 to 18 in 2421018
Is that now anyone contributing to the repo has to understand this new/weird data format. Lines 2 to 6 in f6783e0
Not saying that the Also, very curious what the performance benefit of the P.S. we're definitely not switching this back to |
I had a better look at the
statuses
code and I think we can make the dependency easier to read/use:The following
case
is bothering me:statuses/lib/statuses.ex
Lines 28 to 39 in f6783e0
This case is here to be able to distinguish when the code is run in test and when it is used in another application as a dependency, however it took me a bit of time to understand fully this logic and add to log the
File.cwd
information to check the value on an application using the dependencyWe can have an edge case where the application using the dependency has a file path containing
/statuses
, in this case thecwd =~ "/statuses"
will be true, however the status.json file will not be found by the application.We have created the
statuses.json
that we then read and convert to a list of map in Elixir. Because the dependency is only used with other Elixir application I think we can create directly the list of status map without using json. This would resolve the first point above as we won't have to useFile.read
and make sure the file path is the correct one. The main reason to have a json file is to make it easy to read and update the status, however I feel an Elixir list of map is as readable and can easily be updated, if really required we can add a small description on how to do this on the Readme.So I proposed to refactor the package by:
Statuses
moduleid
tocode
to decouple the status code from the Postgres library and letting Ecto manage the link between status and the application items.@nelsonic let me know if this makes sense, I'll add also comments on my PR #3 to try to explain a bit more my reasoning
The text was updated successfully, but these errors were encountered: