duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest89 has joined #ruby
Glue has joined #ruby
Guest89 has quit [Quit: Client closed]
<Glue>
Hi all. Just a curiosity that has been bugging me: Is there any way to wrap a section of code in such a way that I could output the result of each line like a repl would without prefixing every line with p/puts/whatever? My understanding says there isn't, but it just seems like a neat trick to know if there is.
AndreYuhai has joined #ruby
AndreYuhai has quit [Ping timeout: 276 seconds]
hololeap has quit [Remote host closed the connection]
hanzo has quit [Quit: Connection closed for inactivity]
<ox1eef>
Glue: pry does this, type pry file.rb - at the end it lands you in a pry session.
_ht has joined #ruby
<ox1eef>
my bad, it seems pry does not that feature (anymore i guess)
ruby-eval has quit [Ping timeout: 250 seconds]
_ht has quit [Remote host closed the connection]
Glue has quit [Ping timeout: 252 seconds]
AndreYuhai has joined #ruby
some14u has joined #ruby
Rounin has joined #ruby
oxfuxxx has joined #ruby
jpn has joined #ruby
hololeap has quit [Remote host closed the connection]
mahlon has quit [Ping timeout: 252 seconds]
ged has quit [Ping timeout: 260 seconds]
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jpn has quit [Ping timeout: 276 seconds]
some14u has joined #ruby
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
some14u has joined #ruby
duderonomy has joined #ruby
jpn has joined #ruby
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ox1eef>
the feature im thinking of is the "play" command, you gotta be in the Pry repl to run it.
dionysus69 has joined #ruby
<ox1eef>
ok go ahead
<ox1eef>
whats the problem
<ox1eef>
nvm that
some14u has joined #ruby
some14u has quit [Client Quit]
jpn has quit [Quit: leaving]
some14u has joined #ruby
jpn has joined #ruby
some14u has quit [Client Quit]
ssh073 has quit [Remote host closed the connection]
ssh073 has joined #ruby
oxfuxxx has quit [Quit: [H]EAT ROX FUCK R0X SHIT BRIX. = The Yankies M0th3Rphackers Coconut Aerospace =]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gcd has quit [Remote host closed the connection]
AndreYuh2i has joined #ruby
AndreYuh2i has quit [Client Quit]
AndreYuh2i has joined #ruby
<AndreYuh2i>
How can I make an XHR request in a test?
<ox1eef>
one makes a XHR request using XMLHttpRequest on the client side using javascript, to the server-side it is just another request.
Ziyan has joined #ruby
<AndreYuh2i>
ox1eef: So on the backend we're just making a JS request with format: :js to test something however we receive InvalidCrossOriginRequest, however that just works fine on the environment we have.
<AndreYuh2i>
Does that mean there's something wrong with the test config? Like I don't know what the origin of that request would be.
protektwar has quit [Remote host closed the connection]
Sheilong has joined #ruby
protektwar has joined #ruby
protektwar has quit [Changing host]
protektwar has joined #ruby
<ox1eef>
okay, then you make a request to /foo/bar.js - are you returning javascript from that endpoint? if so then good, if not it doesn't make sense. your spec or test should make a request something like, get :bar, params: {format: :js} - at this point you can test the response.
shiru has joined #ruby
<ox1eef>
you shouldn't receive that error, is it in your tests alone? if so then you're probably missing a header or something like that.
<ox1eef>
a CORS header*
sylario has joined #ruby
<AndreYuhai>
ox1eef: Sorry for the delay, yes it's only in the test.
<AndreYuhai>
ox1eef: I think I am missing the host but I wonder why the host would be different in this case.
<AndreYuhai>
And the endpoint returns a javascript that's correct.
AndreYuh2i has quit [Quit: Lost terminal]
shiru has quit [Quit: Lost terminal]
perrierjouet has quit [Ping timeout: 240 seconds]
<ox1eef>
look into setting the Origin header for the test
John_Ivan has joined #ruby
John_Ivan_ has quit [Ping timeout: 256 seconds]
some14u has joined #ruby
szkl has joined #ruby
<AndreYuhai>
ox1eef: Thank you, will do! By the way, how can I print out the request headers in controller in Ruby? It's been a while since I used Ruby so I don't remember how to do that. :D
<AndreYuhai>
request.headers I guess
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ox1eef>
is this Rails? i think request.env includes them.
<AndreYuhai>
Yes, it is
<ox1eef>
ok, then nevermind, i think request.headers works best
<ox1eef>
the format is just a parameter that's part of the path... something like, /foo/bar.(:format) - so you should pass it like a param.
jpn has joined #ruby
<AndreYuhai>
ox1eef: so it should be inside the params hash right? But I figured even if I deleted it, it just works.
<AndreYuhai>
To overcome the issue I just needed to add "xhr: true" to the get request
<adam12>
Morning
<AndreYuhai>
Then everything was fine and somehow I don't need to mention format: :js
<AndreYuhai>
o/
<ox1eef>
AndreYuhai: that's right, add it to the 'params' hash. i have never heard of the 'xhr' option, so no idea what that does.
<ox1eef>
good morning adam12
<adam12>
ox1eef: Morning! Happy Friday!
<ox1eef>
same to you :)
<AndreYuhai>
ox1eef: it just adds some other headers like "HTTP_X_REQUESTED_WITH"=>"XMLHttpRequest", "HTTP_ACCEPT"=>"text/javascript, text/html, application/xml, text/xml, */*" at least that was the difference
<AndreYuhai>
Where do you actually check when you want to see the docs I am wondering? do you usually use apidock.com?
<ox1eef>
for Rails-specific stuff? i usually just google.
<adam12>
apidock.com is the worst, IMHO
<adam12>
If it's Rails, use their merged sdoc. api.rubyonrails.org
<adam12>
If it's for Ruby, use either official docs docs.ruby-lang.org or rubyapi.org
<AndreYuhai>
adam12: apidock sometimes is useful but for some methods I just couldn't find what I wanted. :D
<ox1eef>
the documentation situation in ruby is depressing.
<adam12>
ox1eef: 100%. It's all I can think about lately.
<adam12>
I wonder who's doing it best (outside of Ruby).
some14u has joined #ruby
<adam12>
I feel like Elixir has reasonably good docs.
<AndreYuhai>
I've been coding in Elixir for a few months and I love the documentation there :D
<adam12>
They are using a Markdown variant.
<AndreYuhai>
Since I've not been using Ruby lately I just couldn't find what I wanted.
<adam12>
(GFM + some other bits)
<ox1eef>
yard does a pretty good job, i find it to be the best of the bunch but still not perfect. it has really nice features like @group, for categorizing your methods. on the other hand, it has things that annoy me - like alphabetically sorting methods, instead of showing them in the order they appear in the source.
<adam12>
AndreYuhai: Do you remember if Elixir has a command line doc tool? I only see HTML and Pandoc in ex_doc.
<adam12>
AndreYuhai: like Ruby's `ri`.
<ox1eef>
Elixir and Ruby are not that different syntax-wise.
<adam12>
I'd hate to introduce another doc tool, but I was thinking about it this morning and wonder what the MVP of docs is.
<adam12>
rdoc auto-links classes/modules (or what it believes are classes/modules), which I think is a mistake.
protektwar has quit [Remote host closed the connection]
<adam12>
AndreYuhai: Right. `irb` has that too, interesting enough, but it's `help`. And I'm not even sure it's documented.
<adam12>
But it loads `ri`. So if you're using YARD, it's not a great experience.
<adam12>
And I've never been able to get `yri` to work.
<ox1eef>
adam12: don't start from scratch, it is a huge effort - i'd consider forking yard, and fixing the things you dislike. i'm already in that process when it comes to the default template.
<adam12>
And due to backwards compatibility, `yard` drives me nuts wrt. command line args.
protektwar has joined #ruby
protektwar has quit [Changing host]
protektwar has joined #ruby
some14u has quit [Ping timeout: 240 seconds]
<adam12>
I feel like everyone is thinking about it lately. I saw ioquatix open an issue on rdoc about support @param and @return tags. He built his own documentation tool as well. https://github.com/ioquatix/decode
<AndreYuhai>
If you have an accept header with "HTTP_ACCEPT"=>"text/javascript, text/html, application/xml, text/xml, */*" then do you need to specificy the `format: :js` in get method still? I mean you don't need to but I just wanted to make sure that's because of the header? :D
<adam12>
That's a wild HTTP_ACCEPT.
<AndreYuhai>
adam12: that's just in test, and it happens when I do "xhr: true"
<AndreYuhai>
And there's no mention of that option in docs, I have no idea how that works
<AndreYuhai>
At least in get method, maybe it's described in some general topic
<AndreYuhai>
With xhr: true, I just saw that there were additional headers added like the ACCEPT one and X-Requested-With
<leftylink>
anya
some14u has joined #ruby
Ziyan has joined #ruby
some14u has quit [Ping timeout: 248 seconds]
John_Ivan has quit [Read error: Connection reset by peer]
John_Ivan has joined #ruby
AndreYuhai has quit [Ping timeout: 240 seconds]
kaleido has quit [Quit: peas]
kaleido has joined #ruby
John_Ivan has quit [Quit: Leaving]
kaleido has quit [Remote host closed the connection]
kaleido has joined #ruby
bit4bit has joined #ruby
_ht has joined #ruby
sgt_chuckles has joined #ruby
John_Ivan has joined #ruby
protektwar has quit [Remote host closed the connection]
<Glue>
Thanks anyway, ox1eef. Repeating p/puts still works if I need it. Really I'm just curious about being able to hook into the results of each line within a block rather than only being able to work with what the block returns. It sounds like generally speaking, there isn't.
<ox1eef>
Glue: there is the "play" command in Pry, it can "play" a file: "play foo.rb", trying it though - it has changed, it is not stepping through every line but the final expression. it was not always that way, i am pretty sure.
AndreYuhai has joined #ruby
AndreYuhai has quit [Ping timeout: 246 seconds]
dionysus69 has joined #ruby
bit4bit has joined #ruby
crundar has quit [Quit: Client closed]
duderonomy has joined #ruby
<ox1eef>
adam12: i made a couple more improvements to the default yard template. The "Table of contents" on a file like README.md is now sticky, following you when you scroll, and it also hides itself on low res devices (<= 1280px)
dionysus69 has quit [Ping timeout: 240 seconds]
TomyLobo has joined #ruby
TomyWork has quit [Ping timeout: 248 seconds]
bit4bit has quit [Ping timeout: 240 seconds]
tuxcrafter has joined #ruby
AndreYuh1i has joined #ruby
AndreYuh1i has quit [Ping timeout: 276 seconds]
<adam12>
ox1eef: Cool.
<weaksauce>
planning on doing something with it ox1eef
bit4bit has joined #ruby
roadie` has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
protektwar has quit [Remote host closed the connection]
protektwar has joined #ruby
protektwar has quit [Changing host]
protektwar has joined #ruby
oxfuxxx has quit [Quit: [H]EAT ROX FUCK R0X SHIT BRIX. = The Yankies M0th3Rphackers Coconut Aerospace =]
<ox1eef>
at the moment i'm just copying it between projects, i think eventually i will make its own repo.
<ox1eef>
my only other wishes are for the 'module Foo; extend self; end' pattern to be covered, and for 'extend' to be its own thing, right now yard refers to extend as included, i think its really confusing.
AndreYuhai has joined #ruby
<ox1eef>
id also prefer 'Class methods' to be described as 'Singleton methods', that's the jargon ruby itself uses, and when yard adds 'Class methods' for what is a module, i dont think it adds up or makes sense.
AndreYuhai has quit [Ping timeout: 246 seconds]
<weaksauce>
i wonder if upstream would want that kind of separation
<ox1eef>
i'm not sure, probably not, i'm sure there's reason and logic behind why it is like it is now. i just disagree with it on a conceptual level.
<ox1eef>
ultimately yard is quite extensible, the changes ive made so far have been made without modifying yard itself.