The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2017-04-11

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:11 disputin joined #mojo
00:16 umask001 joined #mojo
00:40 Lee joined #mojo
00:45 Lee joined #mojo
02:24 noganex_ joined #mojo
02:51 tchaves joined #mojo
04:04 dboehmer_ joined #mojo
05:37 dod joined #mojo
05:44 dod joined #mojo
06:33 inokenty-w joined #mojo
06:45 prg joined #mojo
07:38 dod joined #mojo
08:10 rshadow joined #mojo
08:12 Vandal joined #mojo
08:17 rshadow joined #mojo
08:21 osfabibisi joined #mojo
08:25 ashimema joined #mojo
08:30 trone joined #mojo
10:08 stryx` joined #mojo
10:58 tchaves joined #mojo
11:00 foursixnine joined #mojo
12:06 sri guess i won't be playing nier automata after all... 70 euros is a little expensive when you're not even sure if you'll like the game :o
12:59 dantti_laptop joined #mojo
14:03 zivester joined #mojo
14:48 rshadow joined #mojo
14:55 stryx` joined #mojo
15:14 PryMar56 joined #mojo
15:16 jberger it is interesting how often I see people stumble on the fact that kept alive connections keep the IOLoop active until they timeout
15:16 jberger https://www.reddit.com/r/perl/comments/64q02z/mojolicious_nonblocking_code_example_hangs/
15:34 pink_mist http://i.imgur.com/Rky3Hzw.mp4
15:44 zivester joined #mojo
15:46 disputin joined #mojo
15:48 rshadow joined #mojo
16:28 sri guess the minion admin might be a good opportunity to have a clean bootstrap example https://github.com/kraih/minion/commit/7ef4fadd531dcc7602ac603ea8d98446214e5d15
16:30 sri for stats i wanted to start with something like this http://i.imgur.com/Zr6juQD.png
16:45 sri i might never get around to finishing that branch, but at least i can use it to show what an admin ui pull request should look like
16:56 SwellJoe joined #mojo
17:09 sh14 joined #mojo
17:18 dod joined #mojo
17:23 PopeFelix joined #mojo
17:35 PopeFelix Here's an interesting question. I am working with instances of Future::Mojo, which uses Mojo::IOLoop as a back end. I am mocking a method in a test file, but I want to mock it differently for each subtest.
17:37 PopeFelix Basically what I want to do is insert the mocked method (using Hook::LexWrap) immediately before the calling method calls it.
17:37 PopeFelix So I want to insert the mocking into the queue before the calling method is called.
17:38 PopeFelix How would I go about that?
17:41 jberger PopeFelix I have no idea what you're talking about :-P
17:41 PopeFelix Sorry, it's a bit abstruse, I guess.
17:44 sri first time i've even heard of Future::Mojo
17:44 jberger it has been mentioned before
17:44 jberger but not often
17:44 PopeFelix Well, I'm doing a thing with Paws, and Paws returns Future::Mojo instances when doing things asynchronously.
17:45 jberger but all the mocking immediately before calling methods and something about queueing ... all needs more explanation
17:45 PopeFelix OK, so I'm connecting to Amazon S3, and the Paws S3 client has a method, "put".
17:45 jberger lexical mocking is going to be very hard to do with async stuff
17:45 jberger full stop
17:46 PopeFelix Yeah, that's what I'm discovering.
17:46 Grinnz you can use Class::Method::Modifiers to install more permanent wrappers
17:46 jberger I don't use Hook::LexWrap so I don't know what magic its trying to do
17:46 Grinnz or since Paws is Moose, you can do that by default
17:47 Grinnz but yeah, the "lexical" nature of it would have to be in the scope that the event loop is running in
17:47 jberger but as Grinnz says, you probably need more permanent wrappers
17:47 jberger I have something that might be useful, if I may be so bold
17:47 jberger Mock::MonkeyPatch
17:47 PopeFelix Grinnz, I'm not actually wrapping the Paws methods. For historical reasons, I have a class that wraps the Paws stuff in its own interface. I need to mock that.
17:47 Grinnz well you can apply Class::Method::Modifiers to any method
17:48 * PopeFelix nods at grinnz
17:48 jberger pretty simple module, basically sugar over standard monkeypatching
17:48 PopeFelix jberger, I'm looking at that now
17:48 jberger or CMM works too
17:48 jberger mine is slightly more geared towards testing
17:48 PopeFelix On its face, it looks a lot like Hook::LexWrap
17:48 jberger and it WILL undo its monkeypatching when the scope exits, but basically just because of a scope guard
17:49 rshadow joined #mojo
17:49 PopeFelix right, Hook::LexWrap does that too
17:49 Grinnz ah, wrap can return a scope guard, so you could use that
17:49 jberger then you shouldn't have a problem
17:49 Grinnz you basically just need to keep that around until the callbacks run
17:49 jberger if its a global mock with just a scope limited duration
17:51 jberger Mock::MonkeyPatch was basically just my favorite bits of python's mock class (much reduced, that is a kitchen sink) but with a perlish interface
17:52 jberger there is a more direct clone that I almost used, but the interface is so pythonic that it actually gets annoying that way
17:52 jberger that's Mock::Sub
17:53 jberger python doesn't have cheap ways to build closures, so it has all kinds of ways to manipulate the behavior of the mocked sub
17:53 jberger but in perl, closures are so easy to just build all that stuff is unnecessary
17:55 PopeFelix Yeah, and I tried using the scope guard with wrap, but it broke in one place in a weird way.
17:55 PopeFelix oh well. I'll poke around with it some more.
17:56 jberger was it trying to call some magic pointer to the original function?
17:56 jberger because I actually comment on that type of thing in the Mock::MonkeyPatch docs
17:56 PopeFelix jberger, I wish i knew. it was telling me "The value you provided to Specio::Constraint::Simple->new for parent does not do the Specio::Constraint::Role::Interface role"
17:57 jberger ah, that's a completely different problem
17:57 PopeFelix yeah. I wonder if it's Test::Spec.
17:57 jberger you mocked out something that doesn't conform to the the interface
17:57 jberger this is why Java is hard
17:58 PopeFelix The thing is, though, that I copied the offending block to a separate sketch and it worked fine.
17:58 PopeFelix scope guard or no.
17:58 jberger separate sketch?
17:58 PopeFelix Yeah, i copied the block to a separate file and ran it.
17:59 jberger if its nonblocking then the timing is probably the most important factor
17:59 PopeFelix Yeah, must be
17:59 jberger its why I always have so much trouble producing minimal examples of bugs when I'm doing crazying things that I do sometimes
17:59 PopeFelix yep
17:59 PopeFelix And I do a lot of crazy stuff.
18:00 jberger took me like a month to come up with a good enough example case for sri to fix my websocket timing bug I was hitting
18:00 PopeFelix :D
18:01 gryphon joined #mojo
18:15 rshadow joined #mojo
18:36 ranguard hi, anyone using metacpan api /v0/ - please read https://github.com/metacpan/metacpan-api/wiki/MetaCPAN-V1-announcement-and-migration-plan - sorry for noise here, but quite a few of the regular requests left are using 'Mojolicious (Perl)' :)
18:39 jberger batman: I what does the cpan_mojo bot use?
18:39 jberger err, I **wonder**
18:45 batman probably the old version...
18:45 batman i actually got an email about it now... wonder how they new it was me
18:50 batman new = knew
18:56 [0xAF] joined #mojo
18:58 [0xAF] Hi. How do you terminate template parsing at some point in the template itself. I want to do "% return" in my template at some point, but it wont work as expected. How to get out of the template, without rendering the rest of it?
19:06 gizmomathboy joined #mojo
19:09 batman [0xAF]: that sounds like a bad design. use includes instead and skip the parts you don't want to include
19:10 [0xAF] batman: I thought so... but just wanted to see if there is a way...
19:11 [0xAF] batman: in my case i have a template category.html.ep which will render a category with it's products... but in case there is no products, i would like to be able to exit the template with minimal stuff rendered...
19:11 [0xAF] so, i will redesign my template
19:12 batman %= include "category" category => $category if $category->{products}
19:12 batman or something like that...
19:12 batman the `category => $category` part is redundant...
19:13 [0xAF] yeah, i have something like that for the product_box itself... i guess i will separate the category page too
19:13 batman %= include "category", %$category if $category->{products}
19:13 batman might be a better example ^
19:14 [0xAF] i have another design flaw too...
19:14 [0xAF] i do not have controller for this page and i get my products via helpers in the template itself
19:14 [0xAF] i guess i should create controller which should do it's checks before going to render the template
19:16 [0xAF] batman: thanks for the hints, i was a bit lazy, but the redesign will safe me from future problems i guess...
19:16 batman it's always easier to play by the rules :)
19:16 [0xAF] i guess so ;)
19:23 gizmomathboy joined #mojo
19:31 batman ranguard: is MetaCPAN::Client up to date?
19:31 batman looks like it's using 1.0
19:42 gizmomathboy joined #mojo
19:54 ranguard batman: v0 is what was depreciated, v1 (on new domain name) is current, and yes MC::CLient 2.0 is up to date: https://metacpan.org/changes/distribution/MetaCPAN-Client#L58
19:57 ranguard batman: oh, was me that send email.. sending details over /msg
20:24 batman Ah. Sorry... I'm really tired after running tonight :/
20:24 batman Thanks!
20:39 gizmomathboy joined #mojo
20:46 PopeFelix jberger, Using your Mock::MonkeyPatch combined with a new Future did the trick.
20:46 PopeFelix Basically, it allowed me to put the mocking in the queue before each test executed.
20:55 mishanti1 I don't know how dirty it is considered, but we've been pretty happy with Test::MockModule for mocking in tests.
20:56 mishanti1 Works a charm, and it is pretty easy to cal the $original method when you need to.
20:56 mishanti1 s/cal/call/
21:00 stryx` joined #mojo
21:17 jberger mishanti1 that one looks rather close to mine
21:18 preaction Test::MockModule is kind of cumbersome, really
21:18 jberger mine does a few more things for you
21:18 jberger capturing arguments etc
21:18 mishanti1 Will definitly have a look at that then :)
21:19 jberger but that is very much a personal taste thing
21:19 jberger PopeFelix: glad I could help!
21:21 PopeFelix mishanti1, we had used Hook::LexWrap in other tests at $job, so I figured on using it here.
21:38 onix joined #mojo
21:39 onix I've found a couple of cases where I want to break dispatch with a couple of parallel http requests (to couchdb), is there a good way to get ahead of the dispatcher and see where it's about to dispatch to?
21:40 onix I have the controller in the under, but ...
21:47 disputin1 joined #mojo
22:54 maschine joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary