5 Upcoming Ruby Open Source Libraries Q1 2020 Edition

Neeran Gul
Upcoming Open Source
4 min readMar 15, 2020

--

Image by Peter Lomas from Pixabay

Ruby is one of the most fun languages to develop and prototype in. It has very popular libraries such as Ruby on Rails that make it a strong contender for pretty much all areas. In this story I will go through some new and upcoming open source libraries that can be used for your new or existing projects. The focus here is specifically on libraries that are not fully mature yet and to encourage readers to contribute to them. I highly encourage readers to support the authors in anyway they can whether it is donating, extending functionality or simply using them. Let’s get started.

1. Snapcrawl

Ever wanted to crawl a website and take screenshots? Yes? Then Snapcrawl is the perfect library for you! Snapcrawl uses imagemagick and phantomjs as dependencies to crawl through any website and take screenshots of the web pages. A configuration file can be specified to adjust the depth of the crawl and resolution of the images. This tool is very handy to quickly browse a website when you do not have a GUI and view the results later or to debug bot or user behaviour.

$ gem install snapcrawl
$ snapcrawl example.com log_level=0 depth=2 width=1024

Check it out here: https://github.com/DannyBen/snapcrawl

2. Brutal

Writing tests can be brutally painful but ultimately has a big pay-off. Brutal makes it easy to write repetitive tests and auto generates the tests for you. This tool is great for writing quick tests for your prototypes allowing for others to collaborate and contribute without fearing they might break anything.

# Create a brutal.yml---
subject: |
"Hello " + "%{string}"

contexts:
string:
- Alice
- Bob

actuals:
- "%{subject}.to_s"
- "%{subject}.length"
# Run brutal command on the command line which generates the following:# Brutal test suite

# ---------------------------------------

actual = begin
"Hello " + "Alice"
end

raise if actual.to_s != "Hello Alice"
raise if actual.length != 11

# ---------------------------------------

actual = begin
"Hello " + "Bob"
end

raise if actual.to_s != "Hello Bob"
raise if actual.length != 9

More examples can be found here: https://github.com/fixrb/brutal/tree/master/examples

Check it out here: https://github.com/fixrb/brutal

3. Djin

Running test and build steps inside of Docker containers has essentially become the norm in recent years. It brings many advantages such as the ability to run your code anywhere without worrying about the dependency tree screwing up. Djin is a make-like utility for Docker containers with no need to use tabs ; )

# Create a djin.yml---
# With a docker image
script:
docker:
image: "ruby:2.6"
run:
commands:
- "ruby /scripts/my_ruby_script.rb"
options: "--rm -v $(pwd)/my_ruby_script.rb:/scripts/my_ruby_script.rb"

# Using a docker-compose service
test:
docker-compose:
service: app
run:
commands: rspec
options: "--rm"
# Then run `djin script` or `djin test` to run the above tasks.

Check it out here: https://github.com/catks/djin

Brutal and Djin make a very good combination : )

4. SavIO

Ruby2D is a powerful library for creating 2D interfaces with Ruby. It has a very simple API to create games, apps and other fancy GUI based services. SavIO provides common interaction elements to Ruby2D such as sliders, buttons, input boxes and more as Ruby objects with common properties. Great for creating interactive GUIs that engage the audience.

# SliderslippyTheSlider = Slider.new(x: 830, y: 40, length: 220, draggingEnabled: true, dragType: "duplicate")if slippyTheSlider.value == 69
puts "nice"
end
# ButtonanotherButton = Button.new(
x: 830, y: 150,
displayName: "Enable flux capacitors?",
)
if anotherButton.selected == true do
puts "Flux capacitors now enabled"
end
# InputBoxaskMeAnything = InputBox.new(
x: 830, y: 180, size: 30,
activeColor: 'purple',
displayName: "What would you like to ask?"
)
if askMeAnything.value == "Favorite Color?"
puts "Purple"
end

Check it out here: https://github.com/TheRealSavi/savio

5. terraorg

Imagine you are tasked with implementing a new directory for your organisation, terraorg is a great way to take a code first approach. Essentially you define the teams, members and your whole organisation structure for your company, then terraorg generates Terraform files which can be run using the Okta or GSuite Terraform provider.

provider "okta" {  
# note: specify OKTA_ORG_NAME via environment
# note: specify OKTA_BASE_URL via environment
# note: specify OKTA_API_TOKEN via environment
}
provider "gsuite" {
oauth_scopes = [ "https://www.googleapis.com/auth/admin.directory.group", ]

impersonated_user_email = "g.suite.admin@yourcompany.com"
}
terraform {
backend "gcs" {
bucket = "terraorg-state"
prefix = ""
}
required_version = "~> 0.12.0"
}

The rest of the above example can be found here (its a bit too verbose to be shown here): https://github.com/joshk0/terraorg/tree/master/examples

Checkout it out here: https://github.com/joshk0/terraorg

Wrapping up

Thank you for reading through the list. I will be planning on posting at least 5 upcoming libraries every quarter. If you are working on a new library for Ruby (or any other programming language) please reach out and I will add it to the next edition or feel free to reach out and have your story added to the Upcoming Open Source Publication.

--

--

Neeran Gul
Upcoming Open Source

Industry veteran providing strong mentorship and sharing experiences.