<Matthias1>
Is there a good way to get a class from a ruby file if I don't know the class name?
jenrzzz_ has quit [Ping timeout: 255 seconds]
eddof13 has quit [Quit: eddof13]
fercell has quit [Read error: Connection reset by peer]
fercell has joined #ruby
<[0x1eef_]>
The rails approach is have a convention where foo_bar.rb would define FooBar: TOPLEVEL_BINDING.eval(File.read("./foo_bar.rb"), "foo_bar.rb", 1); unless defined?(FooBar); raise(NameError, "foo_bar.rb did not define FooBar"); end.
<[0x1eef_]>
If you have no idea, then the const_added callback might help.
Linux_Kerio has joined #ruby
Linux_Kerio has quit [Read error: Connection reset by peer]
<Matthias1>
Thanks
gr33n7007h has quit [Ping timeout: 256 seconds]
gr33n7007h has joined #ruby
donofrio_ has quit [Ping timeout: 252 seconds]
hernan has quit [Read error: Connection reset by peer]
hernan has joined #ruby
Matthias1 has quit [Remote host closed the connection]
brokkoli_origin has quit [Ping timeout: 272 seconds]
reddit-bot has quit [Remote host closed the connection]
<sphex>
sam113101: when passed infinity
justache has joined #ruby
<sam113101>
sphex: it wasn't infinity, just a big number
<sphex>
sam113101: huh you're right, seems like it converts the argument to a float so if it was a bigint or something, it could turn into infinity when it wasn't before.
<sam113101>
that sucks
justache has quit [Remote host closed the connection]
justache has joined #ruby
osc4rpt has quit [Ping timeout: 268 seconds]
Axenntio has joined #ruby
<sphex>
sam113101: seems like BigDecimal can do arbitrary precision sqrt.
osc4rpt has joined #ruby
oneeyedalien has joined #ruby
oneeyedalien has quit [Client Quit]
jenrzzz_ has joined #ruby
<sphex>
I guess extending Math.sqrt to support bigints would be a problem because it's expected to return a float. maybe with a new "truncated" keyword argument or something. or "precision"/"round" so that it could return a rational. doesn't seem super worth it to me though tbh...
jenrzzz_ has quit [Ping timeout: 256 seconds]
_ht has quit [Remote host closed the connection]
user71 has quit [Quit: Leaving]
jenrzzz_ has joined #ruby
wyclif has quit [Ping timeout: 255 seconds]
jenrzzz_ has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 240 seconds]
wyclif has joined #ruby
Axenntio has quit [Quit: Axenntio]
jenrzzz has joined #ruby
reset has quit [Ping timeout: 272 seconds]
dalan0382283350 has quit [Quit: dalan0382283350]
dalan03822833508 has joined #ruby
grenierm has quit [Ping timeout: 250 seconds]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 256 seconds]
infinityfye has quit [Ping timeout: 268 seconds]
user71 has joined #ruby
Axenntio has joined #ruby
weaksauce has joined #ruby
weaksauc_ has quit [Ping timeout: 256 seconds]
user71 has quit [Quit: Leaving]
wyclif has quit [Quit: leaving]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 264 seconds]
crivic has joined #ruby
user71 has joined #ruby
donofrio_ has joined #ruby
infinityfye has joined #ruby
jenrzzz_ has joined #ruby
infinity_fye has joined #ruby
infinity_fye is now known as inifnityfye
infinityfye has quit [Killed (NickServ (GHOST command used by inifnityfye!~infinityf@154.180.247.173))]
inifnityfye is now known as infinityfye
jenrzzz_ has quit [Ping timeout: 255 seconds]
dsdxtech has joined #ruby
dsdxtech has quit [Quit: Leaving]
cek has joined #ruby
dsdxtech has joined #ruby
dsdxtech has quit [Quit: Leaving]
dsdxtech has joined #ruby
dsdxtech has quit [Remote host closed the connection]
<monr0e>
Do I need to manually create a gem file in a new project? I'm experimenting with RubyMine and it reports, via the bundler(?) cli, that a gemfile could not be found
<monr0e>
I have GEM_HOME and GEM_PATH set in .bashrc
<adam12>
monr0e: Only required if you're using a Gemfile to manage the project.
<monr0e>
I... I think so? I require Sinatra and a few other packages
<monr0e>
I should point out I've never worked in ruby before, and I'm coming from .NET and Visual Studio so I've a rather bad habit of learned complacency
<[0x1eef_]>
More than likely you want a Gemfile to manage your dependencies, and it's the norm in Ruby - especially in web apps.
<monr0e>
I'm the guy who is avoiding MVC, btw
<monr0e>
I'm just a little lost given that I'm used to my IDE pretty much creating everything I coul dpossibly need
jenrzzz has joined #ruby
<[0x1eef_]>
MVC or not, bundler is useful and solves a different problem.
jenrzzz_ has joined #ruby
<monr0e>
Just out of interest, I assume the bundler installs on a per-project basis and not system-wide?
<[0x1eef_]>
By default bundler will install to your system gems, but once activated it creates a sandbox where only the gems in your Gemfile.lock are available (and the specific versions defined in Gemfile.lock).
<weaksauce>
you're gonna need to drop down to the shell every now and again
<weaksauce>
bundle init
<weaksauce>
and bundle add sinatra
<weaksauce>
etc
<monr0e>
So I need to edit or create Gemfile.lock? Or is it created for me?
<[0x1eef_]>
'bundle install' creates it for you.
<weaksauce>
i don't know if sinatra uses bundler by default but you can add one require and it will setup all the gems to be used
<weaksauce>
require 'bundler/setup'
<[0x1eef_]>
Yeah - you will want to "require 'bundler/setup'" before anything else, that activates bundler.
<weaksauce>
does sinatra have a cli to start the server or is it just rackup
<adam12>
Are you talking about the answer in that SO question?
<monr0e>
yes
jenrzzz has quit [Ping timeout: 264 seconds]
Vonter has quit [Ping timeout: 255 seconds]
<[0x1eef_]>
You can adopt bundler in your current project by adding a Gemfile file to the root of the project, declare your gems in Gemfile, then run 'bundle install'. Finally, "require 'bundler/setup'" when booting the app, likely the first require of all.
<monr0e>
weaksauce: Not a clue. I'm just trying out a few suggestions I got from here a few days ago when I enquired about building a non-MVC webforms app in ruby
<adam12>
So it would be helpful to think of the folder layout of your application in one of two ways. The first is that you're building it as a library (Rubygem) and you might intend on distributing it through Rubygems. That is what `bundle gem ...` gives you.
<adam12>
Actually, stepping back, let's sub application for project.
Vonter has joined #ruby
<monr0e>
So essentially my entire project is a gem? And I can essentially export it as such, in order that I could run it from a server?
<adam12>
So your project is either a library (Rubygem) or application. It can be both, and the layout really doesn't matter for applications, but for libraries they mostly follow a standard.
<weaksauce>
monr0e i guess you just ruby yourproject.rb in sinatraland
<[0x1eef_]>
No. That's not the typical way to use bundler with a webapp. Your webapp is not a gem. It depends on other gems. That answer is not really relevant to you rcontext.
<adam12>
By following the layout from `bundle gem`, you could in the future potentially distribute it as a library.
<monr0e>
But not as a standalone application?
<adam12>
Sure, you could do that as well. The one weird piece from `bundle gem` is the gemspec.
<adam12>
It's mostly meant to be used with libraries and may add some confusion.
<[0x1eef_]>
It will, start simple.
<adam12>
So it might be helpful to make a loose decision now on what you might want.
<weaksauce>
i'd have bin/ app/ test/ dirs as a minimum
<adam12>
The simplest solution is forget about `bundle gem` and essentially start with 3 things. `bundle init`. `bundle add sinatra`. And then a file called `app.rb` or something that has `require "bundler/setup"` and `require "sinatra/base"` in it.
<adam12>
There are best practices you should eventually learn (namespacing, `lib`, etc) but if you're just planning on fucking around to experiment, no point in complicating it.
<[0x1eef_]>
You could turn your web application into a gem, I've done that, but I'm 100% sure it will only cost you time and effort.
<weaksauce>
[0x1eef_] can you expand on when and why you did that?
jenrzzz has joined #ruby
<weaksauce>
i've never found much use in making a gem for my projects
<[0x1eef_]>
The simplest thing you can do is add a Gemfile to the root, declare your dependencies, run 'bundle install', and require 'bundler/setup' when booting your app.
<adam12>
To get going, you only need a Gemfile, Gemfile.lock, and app.rb. Technically you only need app.rb but then you run the risk of the application breaking in the future.
<adam12>
Everything else you can just add-in after the fact.
<adam12>
(and it doesn't need to be called app.rb but I'm simplifying it here)
<monr0e>
ok, so stepping outside a bit, I'm building a web application. It will run as a standalone application on a server, but will also be deployed (eventually) automatically from a set of init scripts, with or without a set of given modules depending on what the (eventual) clients want to pay for. The application is a webforms based application, carrying an internal API for in-module updates and dashboard widgets. There's some external DB access to be
<monr0e>
done, alongside some likely LDAP queries which will be produced by a companion application running on the clients infrastructure. I assume this does not call for a gem-esque approach
<adam12>
I wouldn't.
<adam12>
Normally we just ship the project folder to the server.
<monr0e>
That's what I do in .NET wiht IIS too
<adam12>
Make sure the working directory is set to the root of the folder and then run the app server.
<monr0e>
OK, so assuming an application approach, the libraries that I require will be in the form of... gems?
<weaksauce>
pretty cool [0x1eef_] ... you gemified it to ship it easier?
<[0x1eef_]>
Yep.
<monr0e>
I say libraries, I'm not sure if in the context of ruby I should be saying frameworks
<weaksauce>
gems are libraries
<weaksauce>
frameworks can be gems
<weaksauce>
rails and sinatra are frameworks
<rapha>
and ruby is more than just web development
hightower3 has joined #ruby
<weaksauce>
yes
<weaksauce>
ruby is life
<rapha>
indeed
<weaksauce>
/s
<monr0e>
Ruby is confusing
<monr0e>
but then again, so is development on linux
<weaksauce>
probably less complex than c#
<monr0e>
I suspect I'm making it harder for myself by trying to use rubymine
<adam12>
Rubymine might make it easier, tbh.
<[0x1eef_]>
Rubymine is not how most Ruby developers work. At least that's my impression. We don't usually use IDES at all but an editor alongside a shell.
<monr0e>
weaksauce: C# as an entity yes, but Visual Studio no. VS builds your project in its entirety, lets you pull whatever you need from nuget, and you're ready to create a class, page, extension, etc and just start writing. That's why I mentioned complacency - I've never had to do all the manual labour involved in building the structure first
<adam12>
It will provide some reasonable form of autocompletion out of the box tho, which will be similar to VSCode so there will be _some_ familiarity. Same with refactoring tools (Extract Method, etc)
hightower4 has quit [Ping timeout: 260 seconds]
<adam12>
s/VSCode/Visual Studio
<weaksauce>
monr0e there's a shit ton more boiler plate in c# is why
<monr0e>
That's why I went for it. On paper it appears to have a great deal of support
<monr0e>
weaksauce oh yes. C# is phat
<monr0e>
you can trim it down a great deal, mind, but most people don't bother
<adam12>
monr0e: A lot of stuff in Ruby can be done in a few lines, so there is not a ton of generator-style code I find. If you use Sequel, database setup is a _single_ line.
<adam12>
There are frameworks which pull all the pieces together, with Rails being the most prominent.
<adam12>
So that would be probably closer to your VS experience, but single framework focused.
<weaksauce>
monr0e if you used rails a lot of this would be moot as there are generators just like you are used to... sinatra is very hands off
<monr0e>
I haven't even gotten to DB integration yet lmao.
<weaksauce>
but you'd have to go in MVC
<monr0e>
weaksauce: Problem with rails is that it;s MVC
<monr0e>
I hate mvc
<weaksauce>
what do you want?
<monr0e>
straightforward webforms app
jenrzzz has quit [Ping timeout: 264 seconds]
<weaksauce>
like asp.net webforms app?
<monr0e>
yep
<rapha>
i'd second rubymine being confusing, monr0e. and i can understand linux being a lot to learn at once. what about ruby is confusing, though?
<weaksauce>
isn't that mvc
<monr0e>
weaksauce no, that's mvc
<monr0e>
it's literally called Asp.NET MVC
<monr0e>
and if you reallyhate yourself, you can add Razor
<rapha>
[0x1eef_]: tbf, rubymine is how a lot of _rails_ devs seem to prefer working.
<[0x1eef_]>
Yeah that's probably true. I like to do things the hard way I guess.
jenrzzz has joined #ruby
<rapha>
i also prefer to stay away from it and claim that that's easier.
<weaksauce>
i don't know what mvc in asp.net looks like nowadays but i can't imagine it is fun
<[0x1eef_]>
It's easier once you learn the basics.
<monr0e>
rapha: Just the initial setup. There seems to be a vast number of ways to create a project structure, of which precisely one is included with RubyMine. Since I don't want that specific template (being MVC on rails), I now have to do this on hard mode with zero ruby experience
<weaksauce>
the asp i did a long time ago was awful
<rapha>
monr0e: ok so none of that is ruby (the programming language).
<monr0e>
no, none. I haven't even gotten to that part yet
<rapha>
:(
<rapha>
well, we're here to help.
<[0x1eef_]>
I think it's a Windows vs *nix thing more than anything.
<rapha>
it's just that so often i've seen ruby get a bad rep from what is actually stuff like frameworks or IDEs.
<monr0e>
^^^^^^^^^^
<rapha>
what's razor btw?
<monr0e>
rapha: Yep, seen the same with people coming over to .NET. Ruby in and of itself looks fairly straightforward, which is why I chose it over rust
<monr0e>
rapha: Essentially a markup syntax
<rapha>
oic
<monr0e>
the idea is that you can embed .NET code into webpages directly
<monr0e>
something like angular or react
<rapha>
before long, we might loose our rails client and i might have to learn visualbasic/asp.net. pondering whether that's the right time to quit and find another rails shop. not that i like rails, but i do love ruby.
<monr0e>
there's a lot of @ symbology and it gets very confusing, which is why I despise it
<rapha>
o_O
<[0x1eef_]>
I'm learning Rust and the development model is not that different. I have an editor one one side, a shell in another (with cargo to build and run the project). It's really Windows that never had a good shell, so it doesn't leverage the same model.
<rapha>
isn't there PowerShell now and supposed to be quite good?
<monr0e>
Don't take my opinion as gospel, though. I'm the odd duck, I don't like languages that are designed to be too human-readable
<[0x1eef_]>
Yeah, but that's recent.
<rapha>
ok
<monr0e>
powershell is sort-of-ok. It follows the .NET syntax
<rapha>
monr0e: and then you choose _ruby_? ^^
<monr0e>
ruby is a sensible compromise. I don't like going too far the other way either, so the likes of C++ are not really my thing
jenrzzz has quit [Ping timeout: 272 seconds]
<[0x1eef_]>
ATM my favorite is C
<weaksauce>
monr0e are you going to be storing things in a db? using templates?
<weaksauce>
that's basically all mvc is
<weaksauce>
i think you hate asp.net mvc and not the idea of it
<rapha>
I like C for microcontrollers. But that's probably because Arduino gives me so much hand-holding.
<monr0e>
MVC is a completely different approach to pages in general. I prefer the idea of serving a static page, and then doing any necessary modification client-side.
<monr0e>
MVC calls for the server to update the page
<[0x1eef_]>
rapha: I like its simplicity. It teaches me to do more with less.
<rapha>
i see
<rapha>
that can't be said of Arduino C++. but it can be used like C.
<weaksauce>
at what point are you doing dynamism and need a ruby backend at all then?
<monr0e>
Well, something has to serve as the application layer
<monr0e>
give me a moment, let me see if I can't find an old webapp in .net that I can show as an example
<[0x1eef_]>
monr0e: It sounds like graphql might be your thing.
<weaksauce>
i guess the default paradigm for rails is mvc but there's nothing stopping you from doing static pages/ mvvc / an api to a react frontend etc.
<weaksauce>
all pretty easily
<monr0e>
ok, this is going to take a little while. I'm going to get VS running in a VM, and take a screenshot of the structure alongside the codefiles, that might explain better what I'm trying to accomplish. Back in a bit
<weaksauce>
sure
<[0x1eef_]>
Rails becomes kinda useless at that point. For example, in a graphql application, you typically have one endpoint. You don't use views.
<[0x1eef_]>
Large portions of Rails become bloat that's not used anymore. It doesn't really fit into that paradigm.
<weaksauce>
yeah that's why i'm curious where the application server portion is required over some kind of textfile
<weaksauce>
static html*
* rapha
still wonders if Sinatra wouldn't be the right thing for monr0e
<[0x1eef_]>
Sinatra sounds like a good fit, and if there is no backend at all, then nanoc / jekyll / static site compiler. You can combine a static site with a ruby web server, or just use nginx.
<monr0e>
Sinatra was my original intention
<rapha>
It's just that Rails forces all these opinions on you. And Sinatra just invites you to play a little gig together, whichever song you'd like.
<[0x1eef_]>
That's only become more true in recent times.
<[0x1eef_]>
It's not that it's not possible with Rails but that it doesn't really make sense.
<weaksauce>
i mean you're able to only use what you want from rails too but either way
<[0x1eef_]>
I think graphql is a good example when Rails stops making sense. There's large parts of the stack you won't use. And then you have to question whether the baggage is worth it. I don't think it is.
<[0x1eef_]>
Not that different to using rails as an API. It works but it's not what it was really designed for, and there's better alternatives you can mix + match instead.
<weaksauce>
i guess it depends on what you need the backend to do
<weaksauce>
there's a lot of convenience things you have to tack on that you get for free ootb
<[0x1eef_]>
ActiveRecord would still be useful, activesupport is entirely optional, actionview is optional, large parts of actioncontroller are bloat (you need one endpoint that receives and writes json).
mange has joined #ruby
<weaksauce>
> you need one endpoint that receives and writes json
<weaksauce>
i didn't see that mentioned
<[0x1eef_]>
For GraphQL that's all you need.
<[0x1eef_]>
You POST JSON to one endpoint
<weaksauce>
i'm talking current requirements not how you'd implement it in graphql
<[0x1eef_]>
Oh for monr0e's scenario ? I'm not 100% clear what they're trying to do, sometimes it sounds like a static website.
<weaksauce>
yeah
CrazyEddy has joined #ruby
<monr0e>
prolly gonna be tomorrow before I get this VM going in all honesty. It's almost 11pm here and my brain is like cheese rn
CrazyEddy has quit [Remote host closed the connection]
cata has quit [Quit: WeeChat 4.2.1]
CrazyEddy has joined #ruby
hightower2 has joined #ruby
hightower3 has quit [Ping timeout: 260 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
graywolf has joined #ruby
brokkoli_origina has quit [Ping timeout: 260 seconds]