<nemesit|znc>
jhass: took the active_support route
<nemesit|znc>
DateTime.now.change({ hour: 16, min: 0, sec: 0 }).try { |d| d.future? ? d - 1.day : d }
<jhass>
huh, why the try? did you mean to use then?
baojg has quit [Remote host closed the connection]
<nemesit|znc>
yeah maybe xD
baojg has joined #ruby
nofxx has joined #ruby
dionysus69 has quit [Quit: dionysus69]
rippa has joined #ruby
klaas has joined #ruby
conta1 has joined #ruby
TCZ has joined #ruby
troulouliou_div2 has joined #ruby
baojg has quit []
caterfxo has quit [Quit: leaving]
caterfxo has joined #ruby
kristian_on_linu has joined #ruby
conta1 has quit [Ping timeout: 250 seconds]
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
fluxAeon has joined #ruby
fluxAeon has quit [Ping timeout: 264 seconds]
fluxAeon has joined #ruby
fluxAeon has quit [Ping timeout: 250 seconds]
ooheitooh11 has quit [Ping timeout: 264 seconds]
schne1der has quit [Ping timeout: 250 seconds]
schne1der has joined #ruby
GodFather has quit [Ping timeout: 250 seconds]
wildtrees has joined #ruby
<xco>
hi. i want to create a terminal app with Ruby without the user having to enter irb to execute commands
wildtrees has quit [Max SendQ exceeded]
<xco>
what'll be the best way to approach something like this?
<adam12>
xco: What kind of app?
<xco>
ideally i want the user to be able to type something like "my_app do_this"
<adam12>
xco: In reality, all you need to do is put a ruby shebang at the beginning of your file.
<adam12>
#!/usr/bin/env ruby
<xco>
oh
wildtrees has joined #ruby
<adam12>
Then the rest of the file can be Ruby. You might need to chmod +x the file to make it executable.
<xco>
what if i don't want to chmod the files
<xco>
like when i install rails
<xco>
i can just do
<xco>
rails new bla
<xco>
then it does it straging away
<xco>
straight*
<adam12>
xco: In that instance, rails is your "app"; and someone before you had chmod'd it.
<adam12>
xco: The file that's unpacked in the gem (gem install rails) includes the rails script with executable mode set.
<xco>
oh i see
<xco>
perhaps you know how i can find that?
<adam12>
xco: Which specifically?
<xco>
the executable that will enable me to write my app in ruby, have the user install it as a gem and straigh to work
<phaul>
also the do_this bit is a command line argument. You will need argument parsing as well. Just having a method in the file def do_this won't make it work that way
<xco>
i want to have all those extra steps taken care off
<xco>
phaul yeah that i know that was a quick example :)
<adam12>
xco: bundler includes a comand that will "bootstrap" part of what you need.
<adam12>
xco: But you'll have to write code eventually :) And these are the easy steps.
<xco>
it's easy yet i don't know :D :D
TorpedoSkyline has joined #ruby
<xco>
that's what i want to know
<adam12>
xco: bundle gem your_app
<adam12>
xco: I'd start small, and _learn_ the shebang + chmod.
<xco>
right
<caterfxo>
can rubygems install executables into /usr/bin and / or /usr/sbin ?
<adam12>
xco: You can check out the `bundle gem` command to get you going if you want. I still recommend just starting piece by piece. New file with shebang. Chmod +x. Parse your arguments. You're half way there.
<adam12>
caterfxo: It normally installs them where the ruby binary lives.
markopasha has quit [Read error: Connection reset by peer]
<xco>
adam12 if i do the shebang plus the mod, how do i still get the install to install the CLI and do "my_app do_something --something"?
<xco>
not sure if i'm making myself clear enough
<xco>
:)
markopasha has joined #ruby
<adam12>
xco: Write a gemspec file which packages the file up as an `exe` or `bin`. Build the gem. Install it.
<adam12>
xco: Push it to rubygems, let other people install it.
<caterfxo>
ok. so, because I'm slow, if the ruby binary lives in /usr/bin, then the gems would also be installed in /usr/bin, usually
<adam12>
caterfxo: Yeah. Usually those are just binstubs which point to the real files somewhere else but you are right.
<caterfxo>
sometimes the user can specify some / almost any other fs location, though
<adam12>
caterfxo: I think this can be tweaked through rubygems but I don't remember the incarnation. If you look at `gem env` it will tell you the executable directory.
<caterfxo>
ok. thanks! :-)
TCZ is now known as DontBelieveScien
<adam12>
yw
<xco>
adam12 thank you! :) found what i'm looking for with your help
tainer32 has quit [Remote host closed the connection]
cliluw has joined #ruby
Esa_ has quit []
alfiemax has joined #ruby
<havenwood>
xco: There are two conventions in play, RubbyGem's and Bundler's.
<xco>
thanks :) figured my way out of this
<havenwood>
xco: RubyGems uses the bin/ dir for your gem's executables. Incredibly annoyingly, Bundler decided to use bin/ for developer setup tools and use exe/ for executables. You'll see lots of both in the wild.
<xco>
went for the exe options, works for me so far
<havenwood>
xco: Rubyists know to `bundle` to install deps and `rake` to run tests.
<apotheon>
hmm
<havenwood>
xco: So I'd leave those steps at just that. Make sure those both work. Typically, just a `gemdeps` in you Gemfile and wire up your Rakefile.
<havenwood>
xco: You should `chmod +x` your exectuables yourself. There are no further steps.
<apotheon>
Okay, yeah, now that I think about it, that *is* how I've seen it in Rails jobs.
<apotheon>
I never really thought about it that way, which is weird, because I tend to think about such things.
<leitz>
Why would bundler use "exe"? That's a Microsoft-ism.
vondruch_ has joined #ruby
<havenwood>
leitz: They wanted to accommodate devs adding ./bin to PATH, which I think is an anti-pattern and I regret they didn't follow RubyGems convention for the sake of consistency. I disagree with Bundler's decision on that one.
vondruch has quit [Ping timeout: 256 seconds]
vondruch_ is now known as vondruch
Esa_ has joined #ruby
<leitz>
havenwood, I'm with you on this one. Of course, as I don't use bundler, I don't have much of a say. :)
sauvin has quit [Read error: Connection reset by peer]
Technodrome has joined #ruby
wymillerlinux has quit [Quit: wymillerlinux]
wymillerlinux has joined #ruby
davispuh has joined #ruby
GodFather has joined #ruby
alfiemax has quit [Remote host closed the connection]
BTRE has quit [Remote host closed the connection]
william1_ has quit [Ping timeout: 240 seconds]
BTRE has joined #ruby
sergioro has quit [Quit: leaving]
sergioro has joined #ruby
kevinburke has joined #ruby
Ai9zO5AP has joined #ruby
impermanence has quit [Ping timeout: 264 seconds]
<xco>
if i fetch data from an api endpoint in JSON format, is there a way i can cache the data in a variable, so the the next request for the variable value doesn't go to the API endpoint again?
<xco>
but instead fetches the result it cached locally?
<xco>
so it's faster?
brool has joined #ruby
<havenwood>
xco: Yup.
<xco>
havenwood how? :D
<havenwood>
xco: Many ways!
<xco>
i want just 2
<xco>
best 2
<havenwood>
xco: The threshold question is what HTTP client are you using?
<xco>
HTTParty
<xco>
but i could change
<xco>
i just started building my tool
<havenwood>
xco: You must party hard!
<xco>
i used to before Coronavirus came into the picture :D
<jhass>
you can join the distributed party! unitedwestream.berlin
<havenwood>
xco: Then there are several options. A fun option that I've enjoyed doing is to use Rinda::TupleSpace from the stdlib. You could alternatively just write your own Reaper to clear the cache. I can show you how to do either.
<havenwood>
xco: The example in the Typhoeus readme never expires.
<havenwood>
al2o3-cr: Is there some secondary mechanism to clear keys? Yup, you're right, I just didn't know about it! I haven't read all of Typhoeus' code.
<al2o3-cr>
Typhoeus::Request::Cacheable
<al2o3-cr>
havenwood: yeah, np it's vast lib
william1_ has joined #ruby
nowhere_man has joined #ruby
nowhereman has quit [Read error: Connection reset by peer]
nowhere_man has quit [Ping timeout: 246 seconds]
nowhereman has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<havenwood>
xco: Then that ^ arg is a great option. :)
drincruz has quit [Read error: Connection reset by peer]
nowhere_man has joined #ruby
<MadLamb>
can someone help me with sunspot? I'm getting "RSolr::Error::Http: RSolr::Error::Http - 404 Not Found", but I inspected the values of `Sunspot::Rails.configuration` and they seem to be correct. I can also curl the url and solr responds with `302 Found`
nowhereman has quit [Ping timeout: 240 seconds]
ExoUNX has joined #ruby
wymillerlinux has quit [Quit: wymillerlinux]
wymillerlinux_ has joined #ruby
troulouliou_div2 has quit [Quit: Leaving]
wymillerlinux_ has quit [Read error: Connection reset by peer]
jmcgnh has quit [Read error: Connection reset by peer]
jmcgnh has joined #ruby
GodFather has joined #ruby
NODE has quit [Quit: changing servers]
NODE has joined #ruby
<adam12>
MadLamb: What happens if you tell curl to follow redirects? -L or --location
TCZ has joined #ruby
ur5us has joined #ruby
<MadLamb>
adam12, 200 OK
CommunistWolf is now known as veggies
<MadLamb>
adam12, and I can see the title "Solr Admin"
veggies is now known as CommunistWolf
<MadLamb>
adam12, I was also able to run a filter query with curl
jmcgnh has quit [Read error: Connection reset by peer]
<MadLamb>
adam12, I have the feeling sunspot is messing up. Solr seems to be fine. I can authenticate to the admin, I can see the cores, I can make queries...
pupsikov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<MadLamb>
adam12, The only 404 i get is if I go to the root (hostname:port/) instead of (hostname:port/solr).That page shows a "no context" message and shows the context "/solr -> .....war"
<MadLamb>
and the status code is 404
william1_ has quit [Ping timeout: 264 seconds]
<MadLamb>
the output of `rails runner 'p Sunspot::Rails.configuration'` is `...@user_configuration={"solr"=>{"log_level"=>"WARNING", "path"=>"/solr/default", "solr_home"=>"solr"}}...`
Esa_ has quit [Ping timeout: 264 seconds]
william1 has joined #ruby
<MadLamb>
hmm think I got it
jmcgnh has joined #ruby
GodFather has quit [Ping timeout: 240 seconds]
<MadLamb>
yay got it to work, the issue is no longer Solr
<MadLamb>
it was the SOLR_URL that was wrong. I had to specify the code name, and I didn't
<MadLamb>
core name*
<MadLamb>
spend the whole day fighting with this
ur5us has quit [Quit: Leaving]
william1_ has joined #ruby
cschneid_ has quit [Ping timeout: 264 seconds]
cschneid has joined #ruby
gsingh93- has joined #ruby
gsingh93 has quit [Ping timeout: 272 seconds]
cd has joined #ruby
gsingh93- is now known as gsingh93
cliluw has quit [Ping timeout: 250 seconds]
cliluw has joined #ruby
pupsikov has joined #ruby
cliluw has quit [Ping timeout: 260 seconds]
cliluw has joined #ruby
<xco>
i'm using URI::HTTP.build(host: 'www.example.com', path: '/foo/bar')