/r/ruby

Photograph via snooOG

Celebrate the weird and wonderful Ruby programming language with us!

A sub-Reddit for discussion and news about Ruby programming.

Learning Ruby?

Tools

Documentation

Books

Screencasts and Videos

News and updates

/r/ruby

86,676 Subscribers

6

Anyone interested doing something cool with domain serverless-ruby.org ?

Hey everyone, I'm the owner of serverless-ruby.org. In 2016 it hosted a petition website to bring Ruby lang to FaaS world. Last couple of years it's not really doing anything.

Is anyone interested in doing something cool with it ? Post here or PM me. Thx

0 Comments
2024/12/17
20:50 UTC

2

Ruby with WSL & RubyMine - Am I doing this right?

Started learning Ruby 2 weeks ago via codecademy just to get the basics down. Now on to more advanced resources in my own environment.

I'm on Windows so I set up Ruby via Ubuntu on WSL. I have created a project on my C drive (accessible in WSL via /mnt/c/) so that I can access it through Windows if needed.

Using RubyMine to open the project via the WSL option in Remote Development.

Does this check out to those who are experienced?

Edit: After some research I've realized its best to keep my projects in the WSL filesystem

5 Comments
2024/12/17
17:45 UTC

0

Command not showing, it's invisible!

0 Comments
2024/12/16
22:28 UTC

13

Serving up Quake III Arena using Kamal

Just wanted to share that I'm working on a simple recipe for self-hosting Auake III Arena JS securely with http2.

At present: only single player / multiplayer with bots is available. You can try out the current running instance here, press escape to enter the menu to play either available modes.

Working on the final piece: successfully routing the secure socket wss through the proxy.

2 Comments
2024/12/16
14:49 UTC

2

`block_given?` always return false

Hey guys, I hope you're doing well.

(Context: I'm running this program in WSL2 Ubuntu environment)

I'm doing an inorder traversal on a Binary Search Tree. The method inorder takes the root node and traverses the tree. By traversing I mean printing all the nodes. But here's a catch. Instead of defining it this way, I defined the inorder method to take a block and based on this block, define what you mean by traversing.

This is where I'm having problem, inorder method has a yield(node) call to yield to block, IF you've provided the block. I'm providing it a block but still `block_given?` always return false. As a result, instead of printing all the nodes only root node gets printed.

https://preview.redd.it/mcwy8yvwpy6e1.png?width=855&format=png&auto=webp&s=78e07d0d56c0576c78ac0a41f0492f9f2dbb2182

https://preview.redd.it/m5i6kd6bpy6e1.png?width=1088&format=png&auto=webp&s=4c39458249d577a4fcc9dede035417091a9516ec

https://preview.redd.it/eydq2e6bpy6e1.png?width=800&format=png&auto=webp&s=a555df03ba84c0d466678663aad6228d8392f712

Here's some code snippets, pertaining to above problem.
Here's the full code: https://github.com/atulvishw240/binary-search-tree

22 Comments
2024/12/15
07:09 UTC

31

DragonRuby Game Toolkit - Towers of Hanoi Implementation. Link to source code and playable version in the comments.

8 Comments
2024/12/15
03:39 UTC

14

APICraft now supports both Rapidoc and SwaggerHub

https://preview.redd.it/ujhc3pk6ds6e1.png?width=679&format=png&auto=webp&s=f2a751d9019575f20d568487fdd13606653a47f0

https://github.com/apicraft-dev/apicraft-rails
If you’re a Rails developer looking to simplify API development, Apicraft-Rails is here to transform your workflow.

Designed for API spec first development, this gem empowers teams to collaborate by generating dynamic mocks directly from OpenAPI specifications, ensuring your front-end and back-end can start integration without controller/action implementations.

With real-time contract validation, you can catch discrepancies early, preventing costly rework. Plus, it auto-generates stunning API documentation using SwaggerUI or Rapidoc, saving you time and effort.

Whether you’re building internal services or external APIs, it ensures a streamlined, reliable, and efficient API design process, all with seamless Rails integration.

0 Comments
2024/12/14
09:50 UTC

19

RubyConf 2024 Keynote by Brandon Weaver

4 Comments
2024/12/13
19:12 UTC

55

RubyConf 2024 videos are now available

5 Comments
2024/12/13
17:49 UTC

8

Becoming an Expert Developer

Greetings,
I've been developing with Ruby on Rails for about 6 years, but I've never had a mentor and have always learned everything on my own. The problem is that sometimes I see code from other developers online, and compared to theirs, my code looks like it was written by someone who has been learning for less than a year. I always have the feeling of carrying a huge technical debt. What am I doing wrong? How can I reach that level?

5 Comments
2024/12/13
00:43 UTC

16

rvm when rest of team uses rbenv?

I'll be starting on a contract project next week, and have always used rvm. They mentioned that they all use rbenv. Will there be any issues if I continue to use rvm, while they're using rbenv (all working on the same project)?

33 Comments
2024/12/12
19:43 UTC

3

Parsing RSpec blocks into text blocks

I'd like to parse my test files into blocks of text - Describe, context, it, etc - as happens when rspec runs. Is there a way to load a spec file and just parse the spec? Would a parser do that? Would I have to write something?

Apologies if this is a very known thing I'm missing

7 Comments
2024/12/12
18:18 UTC

2

Status of NMaxtrix gem and alternatives

I'm in need of some linear algebra gem to solve a few physics related problems and I just found NMatrix. Problem is that the last commit dates from 7 years ago and I would like to know if people here would recommend a good, maintained alternative.

2 Comments
2024/12/12
10:20 UTC

4

How to simplify unit test result when there's a dependency between two tests

Lets say we have a unit test component with two tests: test_foo and test_bar. test_foo will evaluate if function foo works. test_bar will use a result come from foo and evaluate if function bar works well. In this setup, I will expect test_bar failed when test_foo fails.

However, in unit testing practice we do not want to add dependencies between test units for some reason (Could anyone explain the reason as well?). If we had a dependency graph between each test units, then we can skip those obviously-will-fail tests and save our lifes. Do we?

On the other hand, what we can only do is create a dependency graph over all failure cases. This could probabily benifit the programmer by quickly locate the core issue in multiple cases. But in practice I never see people doing this or requiring such a feature. Is that just my obversation or people does not care about this?

Update 1: Regarding to eliminating test unit depencencies

It's true that we can always mock dependent class in a test unit. But think of a case I'm in the early stage of a package development and have unstable/experimental interface in my framework. In this case I want unit test captures and interface mismatch in function call sequence. If I'm mocking those experimental interface in unit testing, that means I need to modify those mocks every time I'm changing the interface. This will hugely increase the chance of making mistake on those test units. Then, what will be the best way to test those interfaces without having dependency?

8 Comments
2024/12/11
23:52 UTC

4

Recursive syntax checker

Hi,

Would be nice to have a recursive Ruby syntax checker, in order to catch basic coding mistakes before they hit production.

Although many recommend a combination of UNIX find with xargs, that's fraught with many problems. Most of the relevant flags are nonportable. You have to search for not only .RB files, but also .ERB files. And Gemfiles. and Gemspec files. And extensionless files with Ruby shebangs. And the exit codes tend to slip.

This is perfect fodder for a dedicated linter, implemented in Ruby of course.

Does something already do that?

6 Comments
2024/12/11
23:19 UTC

10

Struggling to install ruby and rails because of OpenSSL?

Hi,

Just for some context of my system:

  • Apple m4 chip
  • Just switched from an older intel laptop to a m4 chip in case that makes any difference.
  • Using rvm to install ruby

Steps I took:
1. rvm install 3.3.6 --with-openssl-dir=\brew --prefix openssl`

2. gem install rails

When I try the command gem install rails I get the following error:

ERROR:  While executing gem ... (Gem::Exception)
    OpenSSL is not available. Install OpenSSL and rebuild Ruby or use non-HTTPS sources (Gem::Exception)
/Users/rahulagarwal/.rvm/rubies/ruby-3.3.6/lib/ruby/3.3.0/rubygems/request.rb:53:in `configure_connection_for_https'

Things I have tried:

  1. brew install openssl
  2. brew upgrade openssl

Both of those yield the result that I am already on the latest version, which at this moment in time is openssl 3.4.0

Is there any advice to fix this? I have been trying different things the whole day to figure this out, I just can't for the life of me install ruby on rails.

Edit:

As a commenter suggested, here is a github gist for the console output that comes up when I try installing ruby.

https://gist.github.com/agarwalrahul1008/003e046232060da2283491fec5f98334

EDIT 2: SOLVED

Ok, so as pointed out by SleepingInsomniac, it was an issue with homebrew. Basically, after I migrated from my intel macbook to my new m4 macbook, it kept using my /usr/local homebrew version instead of /opt/bin. This basically meant that even though I had the relevant openSSL required to get ruby, it didn't matter, since I think it was located in the wrong brew library file.

FIX:

I basically deleted the old homebrew then reinstalled it. Then I used ASDF to install ruby and it went smoothly. Now I religiously pray that my projects that used stuff downloaded from my old homebrew still work.

Thanks so much for all the help everyone!

39 Comments
2024/12/10
12:38 UTC

Back To Top