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
Implement initial parser #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor observations/thoughts LGTM overall to merge.
opts = [strategy: :one_for_one, name: UserAgentParser.Supervisor] | ||
Supervisor.start_link(children, opts) | ||
end | ||
|
||
def parse(user_agent) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For stuuff in this I prefer to only keep application configuration logic, but thats just a nitpick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a helper, the real work is happening elsewhere. I personally think these make for a clean public API with UserAgentPaser.parse("...")
vs something like UserAgentParser.Parser.parse("...")
.
|
||
def parse!(user_agent) do | ||
{user_agents, os, devices} = Storage.list | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pointless newline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not done 😝
safe = | ||
user_agent | ||
|> String.trim | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a preferred style for the newline here? I feel like its made clear that the return is happening due to the lack of indentation. Don't have a strong opinion, just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow, what do you mean @ybur-yug?
@ybur-yug don't get too caught up in code that looks unfinished — it is 😀 . I'd love to get your feedback on the structure of things as it's coming together. |
WHERE IS NAG? |
Damn good question @veverkap! I need to add the config for credo and get it wired up. About to dig in now |
@doomspork my B, misunderstood when you initially told me to peek so I just was being thorough. It all looks rad! Ill keep my eyes on it |
No worries @ybur-yug, I wasn't clear 😀 |
device_replacement: 'Generic Feature Phone' | ||
brand_replacement: 'Generic' | ||
model_replacement: 'Feature Phone' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra whitespace.
@@ -1,19 +1,38 @@ | |||
defmodule UserAgentParser do | |||
@moduledoc """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes coming up with these docs feels like a chore 😛
So unfortunately I just discovered: https://github.com/romul/uap-elixir. I'm not a huge fan of his implementation so I'm going to keep this but will require a repo/app name change, suggestions? Spitballin':
|
I have found others! Still not sure I want to trash this work though... |
Ping @ybur-yug |
I like |
Sounds good @ybur-yug. I can make the changes to the project or if you want to get in some commits you can. |
I can do it later today |
I'll add you as a contributor @ybur-yug 👍 |
Currently a work-in-progress.