faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
inf05 has joined #amber
<inf05> hola
inf04 has joined #amber
<inf04> gg
<inf05> hola lurito
<inf04> pene de gato a la parrilla
<inf05> que tal lurito
inf04 has quit [Client Quit]
inf04 has joined #amber
<inf05> hola
<inf05> comeme el rabo
inf04 has quit [Client Quit]
inf05 has quit [Client Quit]
inf03 has joined #amber
inf05 has joined #amber
<inf03> patxiiiiiiii
<inf05> hola lurito
<inf05> que tal?
<inf05> comeme el rabo
<inf03> dile al gilipollas que tienes a la derecha que se calle
inf04 has joined #amber
<inf05> alex
<inf05> polla gorda
<inf04> quie lo que
inf03 has left #amber [#amber]
inf05 has left #amber [#amber]
<inf04> eeee
<inf04> kk
<inf04> ñ
<inf04> ñ
<inf04> pp
<inf04> p
inf04 has quit [Quit: Leaving]
<FromGitter> <nsuchy> @damianham Thanks for the regex example. I ended up doing authorization on my own and keeping the built-in authentication for identity-purposes only while checking things like the is_admin attribute of the current user on my own.
<FromGitter> <nsuchy> Also if anyone here has suggestions, please reply to: https://forum.crystal-lang.org/t/how-can-i-start-contributing/734
_whitelogger_ has joined #amber
_whitelogger has quit [Ping timeout: 248 seconds]
<FromGitter> <mixflame> let me know if anything is needed
<FromGitter> <nsuchy> Any thoughts on the implementation details?
<FromGitter> <nsuchy> would it be more appropriate to return some sort of exception from the generator, or should I just check if the model name is a keyword, stop the initialization and return some text to the console
<FromGitter> <nsuchy> Here's a pull request I'm working on if anyone would like to comment https://github.com/amberframework/amber/pull/1096
<FromGitter> <Blacksmoke16> is `name` the actual class name? so like it would be `Type`?
<FromGitter> <Blacksmoke16> if so you would want to do like `KEYWORDS.includes?(name.downcase)` so that it would properly match
<FromGitter> <nsuchy> downcasing it isn't a bad idea
<FromGitter> <Blacksmoke16> yes because currently idt this would fix https://github.com/amberframework/amber/issues/995
<FromGitter> <Blacksmoke16> `["type"].includes("Type")` would be false
<FromGitter> <nsuchy> I added a .downcase
<FromGitter> <nsuchy> just now
<FromGitter> <Blacksmoke16> cool
<FromGitter> <nsuchy> Unfortunately we can't make keywords a constant unless it's declared higher up I believe
<FromGitter> <Blacksmoke16> sure you can
<FromGitter> <nsuchy> That leads to a larger question, does Crystal have functionality to determine if a word is a reserved/keyword
<FromGitter> <nsuchy> where would we declare it?
<FromGitter> <nsuchy> Because I get a compiler error
<FromGitter> <Blacksmoke16> outside of `initialize`
<FromGitter> <Blacksmoke16> like where all the properties are declared
<FromGitter> <Blacksmoke16> also dont really need the `of String` is inferred from the contents of the array
<FromGitter> <nsuchy> I can remove the of String if you'd like, that's just to be clear that we're checking as a string
<FromGitter> <Blacksmoke16> might be worth throwing a `# :nodoc:` on the const as well?
<FromGitter> <Blacksmoke16> > that's just to be clear that we're checking as a string ⏎ ⏎ What happens if you did like `def initialize(name : String, fields)`
<FromGitter> <nsuchy> I’ll try that shortly
<FromGitter> <nsuchy> Stepped away from keyboard
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <nsuchy> I can type annotate the name though instead
<FromGitter> <nsuchy> Or we could leave out entirely as it works without
<FromGitter> <Blacksmoke16> imo more type restrictions the better, unless you actually want any type
<FromGitter> <nsuchy> We need a string now
<FromGitter> <nsuchy> Because of the keyword checking
<FromGitter> <nsuchy> So adding a string type restriction seems good to me
<FromGitter> <Blacksmoke16> mhm
<FromGitter> <Blacksmoke16> and just an fyi if you didn't know this. the main point of moving the array to a constant is to prevent it from having to allocate memory for the array every time you new up a Scaffold class
<FromGitter> <Blacksmoke16> as its a constant so only has to be done once. The other option would be to use a tuple instead of an array, i.e. just replace the `[]` with `{}`, tuples are allocated on the stack so are much lighter perf wise, like 10x faster
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ I cut out the keywords to save space when pasting here [https://gitter.im/amberframework/amber?at=5cd0aa784b4cb471d9bc42d6]
<FromGitter> <Blacksmoke16> just something to keep in mind
<FromGitter> <Blacksmoke16> afk a while, driving home
<FromGitter> <nsuchy> No worries. Taking a break anyways. Do tuples have a `.includes?` method too? If so switching is a no brainer. I want my first PR to be as good as possible so every critique is appreciated 🙃
<FromGitter> <nsuchy> Also looking at the issue from a larger perspective should we also perform the same checks on other generators. Could we move keywords up higher and check the same constant on multiple generators? For example the controller and model generators.
<FromGitter> <nsuchy> So we have access to `.includes?`
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> array and tuple both include indexable which include enumerable which gives you includes?
<FromGitter> <Blacksmoke16> probably could yes, could prob declare a module like `module Crystal` and define your constant in there, then reference it via `Crystal::Keywords`
<FromGitter> <Blacksmoke16> prob would be similar to what the stdlib would do as well if they ever include a list in the code
<FromGitter> <nsuchy> I want to go to each generator command and check a central list. Here’s a better question. If we’re doing these checks on multiple generators, which file should `Crystal::Keywords` be defined in?
<FromGitter> <Blacksmoke16> good question
<FromGitter> <nsuchy> A turtle sounds great for our needs
<FromGitter> <nsuchy> Tuple 😂
<FromGitter> <Blacksmoke16> well if its a constant it doesnt really matter much either way
<FromGitter> <nsuchy> Hmm okay
<FromGitter> <nsuchy> As for where to declare the keywords constant...
<FromGitter> <Blacksmoke16> i dont know the file structure enough to have a guess
<FromGitter> <nsuchy> Perhaps src/amber/cli/generators.cr?
<FromGitter> <nsuchy> Since we want to check across all generators
<FromGitter> <nsuchy> There’s even some validation logic in place
<FromGitter> <nsuchy> We could add the keywords check there instead and every single generator benefit
<FromGitter> <nsuchy> Obviously removing it from the current place in the scaffolding file
<FromGitter> <Blacksmoke16> yea sounds like a plan
<FromGitter> <nsuchy> As for adding specs what are the guidelines on those
<FromGitter> <nsuchy> Do we want to add as many as possible or keep them minimal
<FromGitter> <Blacksmoke16> imo there isnt really a point in testing all of it
<FromGitter> <Blacksmoke16> idk what the spec looks like but could do like `Crystal::KEYWORDS.sample`
<FromGitter> <Blacksmoke16> then every run would just pick a random one out of the array :shrug:
<FromGitter> <nsuchy> That seems like a good idea