ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <watzon> Yup I'll be getting some up soon! I've been super busy with work, but as soon as I have some spare time that's my goal
<FromGitter> <watzon> I'll also probably be starting a podcast with a friend from another programming group soon
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <meltheadorable> golly so many podcasts
alex`` has quit [Ping timeout: 248 seconds]
ht_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <watzon> Updated readme https://github.com/watzon/marionette
<FromGitter> <watzon> Damn that was laborious
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter> <drujensen> @watzon 💯 Amber is using the Chromedriver in https://github.com/amberframework/garnet-spec Would be awesome to use this instead.
<FromGitter> <drujensen> remove the Java dependency
laaron has joined #crystal-lang
<FromGitter> <watzon> For sure :) that's why I made it. Java is super heavy, especially when you're trying to run in docker containers. This should be much, much faster and less resource intensive.
<FromGitter> <drujensen> awesome!
<FromGitter> <watzon> If there's anything needed or not working issue reports are definitely welcome for features and bugs. We are already using this at NeuraLegion and it works :)
<FromGitter> <drujensen> Definitely look into this. 👍
ht_ has quit [Remote host closed the connection]
<FromGitter> <drujensen> Trying to get Amber up to Crystal 0.30.0 and hitting this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d4a5e1a4635976e0443e3bb]
<FromGitter> <drujensen> I added an error trace flag but still doesn’t tell me where this is happening
<FromGitter> <drujensen> anyway to figure out which class needs to implement this?
<FromGitter> <drujensen> All the classes that include Enumerable seem to have this implemented
<FromGitter> <watzon> It looks like they dropped the ball on the error's for this change
<FromGitter> <drujensen> ok, did an `ag` in the lib directory. I think I found it.
<FromGitter> <drujensen> thax
<FromGitter> <drujensen> need some help here: https://play.crystal-lang.org/#/r/7d5v
<FromGitter> <drujensen> This is from a library that Amber uses for callbacks
<FromGitter> <watzon> That's really weird
<FromGitter> <watzon> From what I can see it should be working
<FromGitter> <watzon> Ok so I found the problem @drujensen
<FromGitter> <watzon> The yield type isn't matching what the block signature expects
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <andrius> Good morning, I do send instance of class to the listener/hook and I want to restrict hook to use only public methods, is that possible? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d4a6f6b4e17537f52e9f6a7]
<FromGitter> <naqvis> @andrius can you elaborate more? shouldn’t the private methods only accessible within class definition?
<FromGitter> <andrius> lets me check with spec, one sec
<FromGitter> <andrius> you are totally right `Error: private method 'running?' called for Asterisk::AMI`
alex`` has joined #crystal-lang
sorcus has joined #crystal-lang
devil_tux has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 246 seconds]
devil_tux has quit [Ping timeout: 244 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
devil_tux has joined #crystal-lang
laaron has joined #crystal-lang
<FromGitter> <mavu> ```code paste, see link``` ⏎ ⏎ :-( [https://gitter.im/crystal-lang/crystal?at=5d4a96b51dadc42a11291988]
laaron has quit [Client Quit]
laaron has joined #crystal-lang
<FromGitter> <watzon> @mavu what does your `shard.yml` look like?
<FromGitter> <watzon> Should work now
<FromGitter> <rogerwelin_gitlab> Hi all! Question about how to best handle JSON in Crystal. Coming from Go I'm really used to unpack the json into a struct. I trying to do the same thing in Crystal but don't really know how to achieve it or if it's best practice. I have this json mapping: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ However I'm left wondering how to "re-pack" this to a struct. For simple json it's not an issue,
<FromGitter> ... however this is an json array, so can I something in the like of an array of struct? Or is best practice just to return the type JSON:Any ? [https://gitter.im/crystal-lang/crystal?at=5d4a9a3abb5364334cea54d5]
duane has quit [Ping timeout: 248 seconds]
<FromGitter> <watzon> @rogerwelin_gitlab look at https://crystal-lang.org/api/0.30.0/JSON/Serializable.html
<FromGitter> <absolutejam_gitlab> What is wrong with the example you posted @rogerwelin_gitlab ?
<FromGitter> <watzon> As far as your question though I'm confused. What do you mean "re-pack a struct"
<FromGitter> <absolutejam_gitlab> You'll end up with an array of `Node` objects
<FromGitter> <absolutejam_gitlab> or does that not actually work?
<FromGitter> <watzon> It should, as log as `resp.body` is a JSON array of objects that match Node's JSON.mapping
<FromGitter> <absolutejam_gitlab> I'd also say to rename `Nodes` to `Node`
<FromGitter> <absolutejam_gitlab> But that's pedantic
<FromGitter> <rogerwelin_gitlab> @absolutejam_gitlab @watzon ⏎ aah, of course the from_json does what I want it to do, eg. getting the array of Node type that I wanted. No need to turn it into a struct. Sorry misinterpreted how json worked in Crystal =)
<FromGitter> <absolutejam_gitlab> I've heard Go has one of the best json implementations (for a static lang) - Opinions?
<FromGitter> <absolutejam_gitlab> I've not done much Go
<FromGitter> <watzon> It's one of the only things I like about Go tbh
<FromGitter> <watzon> They did a very good job of (de)serialization
<FromGitter> <rogerwelin_gitlab> yeah, I think it's really good, quite intuitive to work with. Also this json to struct tool is very handy: https://mholt.github.io/json-to-go/. Would be nice to have something in Crystal to auto produce json.mapping from a json blob
<FromGitter> <watzon> I actually do have something like that
<FromGitter> <watzon> Although I do want to re-work it so that it can use `JSON::Serializable`
<FromGitter> <watzon> I'll work on getting a hosted version up again tomorrow
devil_tux has quit [Ping timeout: 268 seconds]
<FromGitter> <rogerwelin_gitlab> haha wow, that's awesome!
<FromGitter> <watzon> I try 😊
<FromGitter> <mavu> @watzon works now, thanks :)
<FromGitter> <watzon> You're welcome 😊 have fun with it and make sure to let me know if you have any issues. Feel free to PM me if you need help.
teardown has quit [Ping timeout: 244 seconds]
<sorcus> Hi. Has HTTP::Client option like curl's `--interface`?
<sorcus> > --interface <name> Use network INTERFACE (or address)
<FromGitter> <absolutejam_gitlab> I would doubt it
flaviodesousa has joined #crystal-lang
<FromGitter> <drujensen> @watzon Thank you! makes sense.
<FromGitter> <absolutejam_gitlab> `def self.post(url, headers : HTTP::Headers? = nil, tls = nil, *, form : String | IO | Hash) : HTTP::Client::Response`
<FromGitter> <absolutejam_gitlab> What does the `*` mean?
<FromGitter> <absolutejam_gitlab> I've seen some varargs/splatting but I haven't looked how Crystal does it yet
ua_ has quit [Ping timeout: 258 seconds]
<FromGitter> <naqvis> @absolutejam_gitlab `*` means params after this are `named parameters`.
<FromGitter> <absolutejam_gitlab> oh, I see
<FromGitter> <absolutejam_gitlab> You can do that implicitly too right?
<FromGitter> <absolutejam_gitlab> But I guess the `*` means you *must* supply the param name?
<FromGitter> <Blacksmoke16> for args after it yes
<FromGitter> <naqvis> true, `*` means you need to be explicit
<FromGitter> <straight-shoota> sorcus, no `HTTP::Client` is pretty inflexible right now
devil_tux has joined #crystal-lang
devil_tux has quit [Ping timeout: 245 seconds]
<sorcus> straight-shoota: ok, thank you.
laaron has quit [Remote host closed the connection]
<FromGitter> <absolutejam_gitlab> So, what's `**` in parameters?
<FromGitter> <absolutejam_gitlab> rtfm
laaron has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> like Python's `*args` and `**kwargs` I guess
<FromGitter> <naqvis> Splat `*` is `Tuple` and Double Splat `**` is `Named Tuple`
lucasb has joined #crystal-lang
devil_tux has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <cserb> Anyone else having this problem: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d4acef390bba62a12335fb1]
<FromGitter> <Blacksmoke16> ☝️ August 7, 2019 1:31 AM (https://gitter.im/crystal-lang/crystal?at=5d4a621741d5cd61b5ca8306)
<FromGitter> <Blacksmoke16> @cserb
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <cserb> @Blacksmoke16 thanks
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> https://github.com/crystal-community/jwt 👍
<FromGitter> <absolutejam_gitlab> That and the inbuilt OAuth2 covered my use cases
<FromGitter> <kniknoo> I really like the * and ** separation concepts. It feels like there are explicit parameter zones now.
devil_tu1 has joined #crystal-lang
devil_tux has quit [Ping timeout: 245 seconds]
<FromGitter> <absolutejam_gitlab> But don't they also introduce the ability to specify a parameter that's never used?
<FromGitter> <absolutejam_gitlab> So if you had a typo in your parameter name, or accidentally added in an additional param, you now lose the validation provided by a more concise method signature
<FromGitter> <absolutejam_gitlab> Which is precisely an issue I've fought with for the last 30 minutes haha
<FromGitter> <Blacksmoke16> depends on what you're trying to do
<FromGitter> <Blacksmoke16> they're helpful when you dont know what the args will be
<FromGitter> <naqvis> That’s not problem with them, but its responsibility on developers on how they design their code. Splats are used to receive variable number of arguments or what they called `variadic` in other languages. For sure one can either use or abuse their usage 😆
laaron- has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <absolutejam_gitlab> I agree, but it can make the method signature less concise is all
<FromGitter> <absolutejam_gitlab> And since `crystal docs` doesn't document params, it makes it even more reliable on explicit documentation and examples
<FromGitter> <absolutejam_gitlab> I wish you could prefix a parameter with a comment like you can with properties
<FromGitter> <absolutejam_gitlab> or perhaps a comment block with each of the parameters
devil_tu1 has quit [Ping timeout: 244 seconds]
<FromGitter> <naqvis> comment block is what other languages uses, so I believe we can do the same when documenting function
<FromGitter> <naqvis> at least those will be visible in docs generated
<FromGitter> <Blacksmoke16> hes saying that requires you to manually do it, vs doing something like
<FromGitter> <Blacksmoke16> ```def some_method( ⏎ # Does something ⏎ some_arg : Int32 ⏎ )``` [https://gitter.im/crystal-lang/crystal?at=5d4adb5cbb5364334cec3515]
<FromGitter> <tenebrousedge> eh, docblocks work fine
<FromGitter> <absolutejam_gitlab> that or ⏎ ⏎ ```# some_arg: An awesome number ⏎ def some_method(some_arg : Int32)``` [https://gitter.im/crystal-lang/crystal?at=5d4adb7d950718247797b1d4]
<FromGitter> <absolutejam_gitlab> Probably with a bit more style
<FromGitter> <naqvis> yeah, I got his point, and I was also trying to say that other languages uses the block comment where one has to manually provide the documentation
<FromGitter> <absolutejam_gitlab> I guess you can do what I Just posted above, but I mean, there's no common convention or extra formatting
<FromGitter> <Blacksmoke16> make a PR 😉
<FromGitter> <absolutejam_gitlab> I'd like to eventually, but that's some metaprogramming shit I wouldn't get my head around just yet
<FromGitter> <naqvis> agree
<FromGitter> <naqvis> we should have something like JavaDocs states
<FromGitter> <absolutejam_gitlab> probably an RFC is a good start though
<FromGitter> <absolutejam_gitlab> get it agreed upon
<FromGitter> <naqvis> 👍
<FromGitter> <tenebrousedge> ruby's yard tool does this sort of thing (https://github.com/lsegal/yard/blob/master/lib/yard/verifier.rb)
<FromGitter> <absolutejam_gitlab> and get the parameter types, documentation, output types, block types, etc. all agreed upon
<FromGitter> <wontruefree> @watzon you asked about (this)[https://github.com/wontruefree/qrencode/blob/master/src/qr/code.cr#L75] a while ago
<FromGitter> <wontruefree> sorry I started a new job
<FromGitter> <wontruefree> that is something that can be removed now
<FromGitter> <wontruefree> I was messing with having different outputs like UTF-8 and ASCII but that is just dead code and can be cleaned up
<FromGitter> <meltheadorable> extremely random question — can crystal let you define custom string encodings?
<FromGitter> <absolutejam_gitlab> Can I make `JSON.mapping`/`from_json` run something else?
<FromGitter> <absolutejam_gitlab> Like `Foo.from_json(some_json)` also runs `calculate_time` or something
<FromGitter> <Blacksmoke16> `def after_initialize`
<FromGitter> <Blacksmoke16> runs after `from_json`
<FromGitter> <absolutejam_gitlab> is that part of the JSON module thing?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> er
<FromGitter> <absolutejam_gitlab> sweet, ty
<FromGitter> <Blacksmoke16> no
<FromGitter> <Blacksmoke16> its part of `JSON::Serializable`
<FromGitter> <absolutejam_gitlab> But that's implemented because of `JSON.mapping`?
<FromGitter> <Blacksmoke16> they're separate implementations
<FromGitter> <absolutejam_gitlab> So, I need to add something extra for that to happen?
<FromGitter> <tenebrousedge> @meltheadorable I don't think you can redefine what a string literal is, if that's the question
<FromGitter> <Blacksmoke16> easiest solution would be to just migrate to using the serializable mixin instead of the json.mapping
ht_ has joined #crystal-lang
<FromGitter> <naqvis> My understanding of Melody question is, can we use encoding other than default `UTF8`.
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
fyber has joined #crystal-lang
duane has joined #crystal-lang
<FromGitter> <meltheadorable> @tenebrousedge not for literals, but i also didn’t realize that crystal treated strings as exclusively UTF-8, ruby lets you set both the underlying byte representation for a string and which encoding to interpret the underlying byte representation as, i foolishly assumed crystal was treating strings more as the abstract type and could allow converting between differently encoded ones in a similar way
<FromGitter> ... somehow, which is my bad, that changes the questions it makes sense to ask
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/String.html#encode(encoding:String,invalid:Symbol?=nil):Bytes-instance-method could use this?
<FromGitter> <meltheadorable> it looks like the answer to my question is “no” based on looking at that
<FromGitter> <tenebrousedge> I'm not sure what sort of interface you'd like to use
<FromGitter> <meltheadorable> context — i often deal with sequences of bytes that are strings but not in any known/defined encoding, i’d love to be able to create a class or whatever that you can use with strings to convert from/to these custom-defined encodings, which is something ruby doesn’t let you do easily, like, I can’t specify my custom encoding type and then tell ruby to use that encoding to convert the string, and
<FromGitter> ... it’s pretty hard to represent byte literals in a way that would define the mapping to do in application layer code, it’d be nice to be able to use the string encoding facilities in crystal to define new encodings, but it looks like crystal might be using an external library to source the encodings it knows about & there’d be no way ... [https://gitter.im/crystal-lang/crystal?at=5d4af05dd835f428ec458d5a]
<FromGitter> <tenebrousedge> it does use an external library, but it would also be possible to override `String#encode`
<FromGitter> <meltheadorable> yeah, but not in a useful way
<FromGitter> <tenebrousedge> what encoding are you working with?
<FromGitter> <meltheadorable> a lot of totally unique ones — i toy around with ROM hacking which for folks who don’t know is basically just messing with the cartridges and save files of old video games, and most games each defined their own byte <-> string representation, it’d be great if i could treat these like actual string encodings though instead of like, constructing hashes and then manually processing bytes to convert
<FromGitter> ... back and forth between UTF-8 for displaying and taking input vs. what I read/write back in binary form
<FromGitter> <meltheadorable> even if that’s what’s going on under the hood, it’d be great to be able to hide that more as an implementation detail and make the parts actually dealing with the strings a little more understandable
<FromGitter> <meltheadorable> not a huge deal, crystal is just already a lot cleaner for dealing with bytes than ruby is, it’d be nice to also be better for handling conversions between strings and bytes with custom encodings
<FromGitter> <meltheadorable> i’m not sure what would have to change to make that possible though
<FromGitter> <naqvis> @meltheadorable what about `String#new` (https://crystal-lang.org/api/master/String.html#new(bytes:Bytes,encoding:String,invalid:Symbol?=nil):String-class-method) with `encoding` param and Slice?
<FromGitter> <naqvis> since you have the `Bytes` and you know the encoding, then you can still make that as String
<FromGitter> <naqvis> seems link didn’t work, I was pointing to below `constructor` ⏎ ⏎ ```def self.new(bytes : Bytes, encoding : String, invalid : Symbol? = nil) : String``` [https://gitter.im/crystal-lang/crystal?at=5d4af38d90bba62a12347ac1]
<FromGitter> <meltheadorable> @naqvis they aren’t “real” encodings, that’s what I’m saying — I’d need the ability to define a new encoding so that I could pass that in as a param to handle the conversion
<FromGitter> <tenebrousedge> `String.new` calls `String.encode`
<FromGitter> <tenebrousedge> so you can check the args and call `super` for ones you don't want to handle
<FromGitter> <kinxer> @meltheadorable This sounds like a prime opportunity for a shard.
<FromGitter> <naqvis> Then I guess you will have to implement methods like `String#to_utf16`, `String#from_utf16` and do the encoding conversions there
<FromGitter> <meltheadorable> i’m not sure how it’d be implemented/able as a shard
<FromGitter> <naqvis> implement `to/from` methods and do monkey patching? that will ensure those encoding conversions methods are available on `String`. Just one thought to keep the ball rolling 😆
<FromGitter> <meltheadorable> `to_from` methods wouldn’t be workable, there’d need to be some kind of encoder/decoder interface
<FromGitter> <tenebrousedge> a module/shard would presumably have its own module for methods, and then re-open `String` and add the interface to call the module methods
<FromGitter> <kinxer> You could monkey-patch `String` with `String#encode(encoding : CustomEnc::Encoding)` and `String#decode(encoding : CustomEnc::Encoding)`, where `CustomEnc::Encoding` is a class you've written. As monkey-patching goes, that should be pretty safe, too, since Crystal's type safety should prevent any collision with other shards or `String` patches.
<FromGitter> <kinxer> I was trying to come up with an example, but I realized I don't know enough about string encoding conversion as a problem.
<FromGitter> <meltheadorable> Yeah, i’d have to think really hard about what would make sense and I haven’t yet
<FromGitter> <meltheadorable> idk what my ideal interface would look like
<FromGitter> <kinxer> Do you want compile-time encoding definitions or runtime encoding definitions?
<FromGitter> <meltheadorable> not sure
<FromGitter> <meltheadorable> no wait, compile time is fine/preferable
<FromGitter> <meltheadorable> those are known by then
<FromGitter> <meltheadorable> i might for one of my projects eventually need runtime ones but that can be built as app-level functionality, it makes sense in those scenarios to do that
<FromGitter> <meltheadorable> (for example, a lot of hex editors will allow you to import character tables that provide a byte -> character map it can use to preview and allow you to edit text content more easily, that would need to be runtime, but it’s fair to build a runtime layer for that, there’s cases where i’d need this compile time too)
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <meltheadorable> I wonder what it would take to make this manageable at a language level, I think to do this right, a shard would need to override some private/protected stuff pretty deep in the encoding guts for IO, there may be a way to surface an abstraction that would allow Iconv to just be one implementation for IO encoders, might have to play with this a little this weekend
rohitpaulk has joined #crystal-lang
duane has quit [Ping timeout: 248 seconds]
duane has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<jokke> hey
<jokke> is it still possible to append items to array literals from macros?
<jokke> hm seems so
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <bew> Soon some automated specs on windows? https://circleci.com/blog/windows-general-availability-announcement/
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
ukd1 has joined #crystal-lang
ukd1 has quit [Client Quit]
ukd1 has joined #crystal-lang
duane has quit [Ping timeout: 246 seconds]
Nekka has quit [Read error: Connection reset by peer]
<FromGitter> <absolutejam_gitlab> So, `OAuth2::Client.get_access_token_using_authorization_code` returns a `OAuth2::AccessToken`
Nekka has joined #crystal-lang
MasterdonX has quit [Ping timeout: 245 seconds]
<FromGitter> <absolutejam_gitlab> And this has a property `expires_in`
<FromGitter> <absolutejam_gitlab> But I want to track the actual time it expires and add a `expired?` method. I have a custom class that has these properties atm, and i'm going OAuth2::AccessToken -> json -> new class to get this info
<FromGitter> <absolutejam_gitlab> What's the best way?
<FromGitter> <absolutejam_gitlab> I guess I can re-open the class right? And add these?
<FromGitter> <absolutejam_gitlab> I forgot about that
Nekka has quit [Quit: zzz]
Nekka has joined #crystal-lang
<FromGitter> <tenebrousedge> 👍
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
ukd1 has quit [Quit: leaving]
ukd1 has joined #crystal-lang
<FromGitter> <Blacksmoke16> if the access token is a JWT you wouldnt really have to worry about it
<FromGitter> <absolutejam_gitlab> It aint
<FromGitter> <Blacksmoke16> :sad:
<FromGitter> <absolutejam_gitlab> I have a JWT implementation and an OAuth implementation
<FromGitter> <tenebrousedge> how would you not have to worry about it?
teardown has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> JWT don't have refresh token
<FromGitter> <Blacksmoke16> because the JWT itself contains the `exp` property
<FromGitter> <Blacksmoke16> which is checked when validating it
<FromGitter> <Blacksmoke16> API i use often uses JWT tokens as the access tokens, plus refresh_tokens for getting new JWTs
<FromGitter> <tenebrousedge> oauth tokens also have an `expires_in` property
<FromGitter> <tenebrousedge> what's the difference?
ukd1 has quit [Read error: Connection reset by peer]
ukd1 has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Is there a way to deserialize json from a nested key to an object
<FromGitter> <absolutejam_gitlab> So if the json I get back is `{ "items": [ { an object }, { an object } ]}`
<FromGitter> <absolutejam_gitlab> Can I pull out the items directly into an array of whatever class I have defined for it?
<FromGitter> <tenebrousedge> isn't that the point of JSON::Serializable (https://crystal-lang.org/api/0.30.0/JSON/Serializable.html) ?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> @tenebrousedge i mean for oauth tokens you need both the access_token and the value of that property
<FromGitter> <Blacksmoke16> for JWTs you just need the access_token itself
<FromGitter> <Blacksmoke16> @absolutejam_gitlab thats possible yes
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d4b343ec87a0963e72defbc]
<FromGitter> <Blacksmoke16> could do same thing with `JSON.mapping` as well...
<FromGitter> <absolutejam_gitlab> That still means I have to delve through the objects right?
<FromGitter> <absolutejam_gitlab> Like if the json was 3 levels deep that i actually wanted
<FromGitter> <absolutejam_gitlab> I've used `JSON.mapper` to do that before, going `foo.bar.items` where each of them is a class that is mapped to
<FromGitter> <tenebrousedge> there's `Array#dig`, if that helps
<FromGitter> <absolutejam_gitlab> mapping*
<FromGitter> <Blacksmoke16> unless you define some method at a higher level that does that logic for you
<FromGitter> <Blacksmoke16> i.e.
<FromGitter> <Blacksmoke16> ```class Items ⏎ include JSON::Serialzable ⏎ ⏎ property items : Array(Item) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d4b34df90bba62a12365256]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d4b34fb2612bb718c2932d6]
<FromGitter> <absolutejam_gitlab> I just didn't want a load of 'filler' classes if they're just used to dig deeper, but it's not an issue
<FromGitter> <Blacksmoke16> you can also do something like
<FromGitter> <asterite> You can always do it like this: https://play.crystal-lang.org/#/r/7db2
<FromGitter> <asterite> but defining classes is good because you can reuse the shape in other parts of the code
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d4b35cea4efe3718dc148a9]
<FromGitter> <Blacksmoke16> but that only allows accessing one element deeper
<FromGitter> <Blacksmoke16> and they cant repeat
duane has joined #crystal-lang
<FromGitter> <Blacksmoke16> always thought it would be a nice feature to have like `@[JSON::Field(path: ["path","to","value"])]`
<FromGitter> <Blacksmoke16> which would set the ivar to the value at the end of the given json path
<FromGitter> <Blacksmoke16> but would be tricky to implement
<FromGitter> <Blacksmoke16> another benefit of defining the classes is it preserves the structure when you do `.to_json`
<FromGitter> <Blacksmoke16> records are a good option if the data you're consuming is immutable
<FromGitter> <Blacksmoke16> ```record Items, items : Array(Item) do ⏎ include JSON::Serializable ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d4b36c6d03a7c63e6e913e2]
ht_ has quit [Quit: ht_]
MasterdonX has joined #crystal-lang
diverger has joined #crystal-lang
go|dfish has quit [Ping timeout: 245 seconds]
<FromGitter> <jwoertink> Does crystal 0.30 ship with shards 0.9.0?
<FromGitter> <jwoertink> I just upgraded, but my shards version is still the same. Or is that supposed to be a different update process?
<mps_> jwoertink: shards is separate package from crystal
<FromGitter> <jwoertink> right, but when I installed earlier versions through home brew, it also installed shards
<FromGitter> <jwoertink> I never had to install shards separately
<FromGitter> <jwoertink> but crystal 0.29 was released on jun 6th, and shards 0.9 on june 12th. I assumed upgrading to crystal 0.30 would also updated shards, but I guess that's not the case?
<FromGitter> <jwoertink> maybe it was supposed to be, and just missed?
<mps_> not for now, afaik
<mps_> I upgrade them separately as they released
<FromGitter> <jwoertink> ah. Ok
<FromGitter> <jwoertink> Anyone here using crystal with `asdf`?
<FromGitter> <jwoertink> I'm wondering if there's a way to tell it to use crystal with a different version of llvm
<FromGitter> <jwoertink> mine is using `6.0.1` right now
duane has quit [Ping timeout: 245 seconds]
duane has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron- has joined #crystal-lang
laaron has joined #crystal-lang
laaron- has quit [Ping timeout: 260 seconds]
laaron has quit [Remote host closed the connection]
sorcus has quit [Ping timeout: 264 seconds]
laaron has joined #crystal-lang
<FromGitter> <denolfe> I use asdf, but I've never played around with different llvm versions. Mine says 4.0.0
<FromGitter> <denolfe> Worth noting that my `shards` is in-fact using the one that was installed with asdf
Nekka_ has joined #crystal-lang
ukd1_ has joined #crystal-lang
ukd1 has quit [Ping timeout: 248 seconds]
Nekka has quit [Ping timeout: 244 seconds]
Nekka_ is now known as Nekka
alex`` has quit [Ping timeout: 258 seconds]
lucasb has quit [Quit: Connection closed for inactivity]
ukd1_ has quit [Ping timeout: 245 seconds]