Ruby Icon

Ruby

Ruby is a scripting language designed for simplified object-oriented programming.
331 Stories
All Topics

Ruby github.com

Elixir/Unix style pipe operations in Ruby

This is a proof of concept, but oh what a concept! I freakin’ 💚 Elixir’s pipe operator, hope they’ll add it to JavaScript, and would trade half my kingdom to have it in Ruby.

"https://api.github.com/repos/ruby/ruby".pipe do
  URI.parse
  Net::HTTP.get
  JSON.parse.fetch("stargazers_count")
  yield_self { |n| "Ruby has #{n} stars" }
  Kernel.puts
end
#=> Ruby has 15120 stars

Phusion Blog Icon Phusion Blog

Using GitHub Actions to build and publish a Ruby gem

Follow along as our friends at Phusion walk us through the process of creating a GitHub Actions workflow to build and publish a Ruby gem to the RubyGems registry.

One of the actions featured in the version that’s currently exclusively available to GitHub employees and a selected and undisclosed group of Beta testers, is the ‘GitHub Action for npm’, which wraps the npm CLI to enable common npm commands.

We set out to instead make an example workflow to build and publish a Ruby library (or: gem) to the default public registry, and created a GitHub repository, with a Docker container for a ‘Rubygems’ action: github.com/scarhand/actions-ruby

Ruby bundler.io

Announcing Bundler 2.0

Congrats to the Bundler team (and entire Ruby community) for shipping an awesome update to this critical piece of infrastructure! Bundler truly changed the game for Rubyists around the world and we continue to benefit from its goodness.

What’s new in 2.0? A lot, but I’ll cherry pick a minor change that made me smile:

Changed the github: 'some/repo' gem source to use the https schema by default

Finally! That’s worth the price of admission from where I’m sitting. Also:

With the release of Bundler 2, the core team now kicks off a new release schedule for Bundler: we’re going to aim for one major version release per year, so we can drop support for older Ruby and RubyGems versions around the same time that the Ruby core team does. Being able to stop supporting Ruby 1.8.7 is a huge relief!

To the future!

David Heinemeier Hansson Ruby on Rails blog

Action Mailbox for Rails 6

DHH announced on the Ruby on Rails blog the details behind Action Mailbox, the second brand new framework coming to Rails 6 (the first was Action Text). Action Mailbox routes incoming emails to controller-like mailboxes for processing in Rails.

The framework was, like Action Text and Active Storage, extracted from Basecamp 3. We’ve been using a related approach to route everything from forwarded emails to email replies to messages and discussions. After extracting the ideas into Action Mailbox, we reintegrated the framework into Basecamp, and we’ve been running the code we’re sharing today for over a month in production.

German Velasco Thoughtbot

Is Elixir a scripting language?

Finally, an article that breaks Betteridge’s law of headlines!

Elixir is known for being a language made for building distributed applications that scale, are massively concurrent, and have self-healing properties. All of these adjectives paint Elixir in a grandiose light. And for good reasons! But is Elixir also a language that can be used for the more mundane tasks of this world like scripting? I think the answer is a definite yes.

I’ve been writing Elixir for a few years now, but when it comes time to script something I still reach for Ruby. Case in point, our data import routines for changelog.com (which y’all know is an Elixir app) are written in Ruby.

Why do I do this? Familiarity plays a big part. Also I find Ruby to be highly ergonomic for such tasks. Having said that, this article will make me consider trying Elixir for my next script.

David Heinemeier Hansson weblog.rubyonrails.org

Rails 6 will provide a built-in rich text editor

DHH announces Action Text, a big new feature coming to Rails 6:

It’s an integration between the Trix editor, Active Storage-backed file and image processing, and a text-processing flow that ties it all together. With Action Text, you really shouldn’t ever have to impoverish your users with a vanilla textarea ever again!

I’m a bit torn on this. On one hand, Trix is a good tool and many (most?) web apps need rich text editing at some point in their lifespan. On the other hand, it’s difficult to build general purpose features like this that span both the front and back ends of the stack.

Rails 6 is a ways away (with betas starting in early 2019), so we’ll have to wait and see. Regardless of whether this particular feature pans out, it’s great to see the Rails team continue to innovate and try new things.

Rails github.com

Stories — a self hosted Medium platform built with Ruby on Rails

Looks-wise, this is an exact design clone too. Hope that doesn’t get anyone who uses this “as is” in any trouble with the real Medium.

This project is a fork of a Medium clone which began as Ken Hibino’s personal side project to learn Rails and React. I upgraded and refactored parts of the Rails app and integrated Dante2 wysiwyg editor.

If you’re looking for commentary around the project or Rails, check Hacker News.

Rails medium.com

Powering your Ruby & Rails development with Pry

I use Pry (a runtime developer console) all the time and I still learned a few tricks from this post. Here’s a doozy for working in Rails apps:

there’s show-routes , which does what the name implies, and also takes a -G flag for grepping. No more starting up a new shell to execute rake routes | grep login and wait for it to boot up Rails just to give us the routes on the side!

This is the one and only tool that i miss when working with Elixir and Phoenix. Yes, I know there’s IEX.pry built in, but it doesn’t offer as smooth a workflow as Ruby’s pry. Maybe someday…

Lyndsey github.com

🎯 The best fastlane plugin to understand and tame misbehaving iOS tests

Lyndsey Ferguson:

Unit testing and the tests themselves are written by humans. Humans are prone to error. Unit tests and the testing infrastructure can be imperfect. The test_center plugin includes tools that remove (or alleviate) the effects of an imperfect test infrastructure.

(fastlane is a popular way to automate building/releasing iOS and Android apps.)

TensorFlow github.com

A pure Ruby implementation of a TensorFlow-like library with provisions for hardware acceleration

A reimplementation of TensorFlow for Ruby. This is a ground up implementation with no dependency on TensorFlow. Effort has been made to make the programming style as near to TensorFlow as possible, comes with a pure Ruby evaluator by default with support for an opencl evaluator for large models and datasets.

Ruby github.com

Stealth – a Ruby framework for creating conversational bots

This is a lot like Ruby on Rails (even with ActiveSupport & ActiveRecord built-in), but instead of views you have replies. It works for both voice-based and text-based bots and has NLP offerings baked in too. 🍰

The only bummer is that service integrations are currently limited to Facebook Messenger and Twilio SMS. That’s pretty normal for a new open source offering, though, and it’s a great place to hop in and contribute.

Ruby blacktm.com

A guide to getting started with Ruby on WebAssembly

Tom Black:

With the advent of WebAssembly, the race is on to bring new languages to the web. This is the first example (I think!) of a Ruby interpreter running in the browser.

The path to get there is circuitous.

Ruby script → MRuby bytecode → C → emcc → LLVM → Binaryen → WebAssembly

The good news is access to that path is just a gem install wasm away. Read the entire post for some great context and history around these efforts.

Rails rollbar.com

Top 10 errors from 1000+ Ruby on Rails projects (and how to avoid them)

Nice post by our friends at Rollbar:

We looked at our database of thousands of projects and found the top 10 errors in Ruby on Rails projects. We’re going to show you what causes them and how to prevent them from happening. If you avoid these “gotchas,” it’ll make you a better developer.

I know many of these like the back of my hand. 🤣…😭

Top 10 errors from 1000+ Ruby on Rails projects (and how to avoid them)

Chris Frank github.com

Dynamically filter and sort data via URL params in any Rack app

If your Ruby/Rack app renders a list of database records, and you want those records to be filterable via URL params, Rack::Reducer can help.

I like that this is Rack-focused, since Rails already has plenty of solutions in this space. The README includes examples of use with Sinatra, Hanami, Roda, and other commonly used Ruby web libraries.

The Changelog The Changelog #286

JavaScript sprinkles in Basecamp turned Stimulus

David Heinemeier Hansson (DHH) shares the story of how JavaScript sprinkles in Basecamp evolved into a full-fledged framework called Stimulus. We talked about ins and outs of Basecamp as it is today, Ruby, JavaScript, David’s somewhat new found love for JavaScript, how they open source because they can, and David’s new YouTube series called “On Writing Software Well”.

Ping! Icon Ping!

Resque::Fifo::Queue

A sharded First-in First-out queue using Redis and Resque.

This gem unables you to guarantee in-order job processing based on a shard key. Useful for business requirements that are race-condition prone or needs something processed in a streaming manner (jobs that require preservation of chronological order).

Ruby github.com

A lightning fast JSON:API serializer for Ruby objects

The Netflix team managed to squeeze out some huge performance improvements over Active Model Serializers:

We want to ensure that with every change on this library, serialization time is at least 25 times faster than Active Model Serializers on up to current benchmark of 1000 records.

At first glance I thought this was a drop-in replacement for AMS, which would’ve been epic, but it has its own API. That being said, its API is pretty similar and looks easy to use.

Exactly how much faster is this library? It can serialize 250 records in 3.01 ms vs AMS’s 138.71 ms!

  0:00 / 0:00