If I want to validate an IP address String using only ruby's stdlib, should I use `IPAddr::RE_*` regexps or Resolv's regexps?

Also, I wonder if there is a performance hit for including too many Module.new instances into a class?

Also you should checkout command_kit. I'm having a blast writing these CLI commands with it.

Show thread

Is there an easier way to pass configuration to a `self.included` method of a module than the old `class Mixin < Module` trick?

I'm trying to DRY up some repeated CommandKit command-line options which are defined in the class into modules, but I also want to allow overriding certain configuration (ex: desc or the callback block).

There's this annoying calling convention pattern I keep running into:

* When `foo: true` is given, enumerate over the default values for `foo`.
* When `foo: [...]` is given, only enumerate over those values.
* When no keyword arguments are given, enumerate over some default set of values or perform some default action.

Is there a reason why Net::HTTP decided to call this method `form_data` instead of `post_params`? Tempted to rename it to `post_params` in my HTTP wrapper API.

In liue of grumblings about rubocop's pedanticness, is there a *simplified* Ruby style guide I can link to in a CONTRIBUTING.md file? rubystyle.guide is far too detailed to be considered light reading...

Is there a maximum unicode codepoint value for all of Ruby's Encodings? 0x10ffff appears to be the maximum value for most Encoding::UTF_* encodings I tested.

# => "\u{10FFFF}"
(irb):11:in `chr': 1114112 out of char range (RangeError)

but I might also want to select a random User-Agent based on the suffix (ex: `:*_ipad` or `:*_macos`). So scanning a single Hash probably might be a better idea.

Show thread

This came about in my code where I have a constant Hash of User-Agent strings with Symbol IDs. I need to be able to select a random `:chrome_*` User-Agent from the Hash. I suppose I could split the Hash constant into multiple sub-Hash constants (ex: `CHROME_USER_AGENTS`) and merge them back together into a single Hash at load time.

Show thread

Is there an easier way to get a random value from a Hash for keys that begin with a certain prefix? Best I can think of is:

hash.select { |k,v| k =~ /prefix_/ }.values.sample

I'm also curious how you distribute RBI or RBS type files to be consumed? Do you create a sig/ or types/ directory in each library's repo? If you're generating RBI/RBS type files for a multi-library framework, do you create a single rbs or rbi repo that contains the type files for all of the libraries?

Show thread

I managed to fix most of the warnings from sord, but it's still complaining about not knowing about TCPSocket or OpenSSL, etc. I assume this means some poor soul (hopefully not me...) has to write RBS/RBI type signatures for the various parts of stdlib, so the code which touches stdlib Objects can also be validated.

Show thread

Although it's complaining about `Hash{String => String,nil}` which I thought was valid syntax for saying the Hash values can be either a String or nil.

Show thread

Playing around with sord, and WOW this thing is GOOD at finding missing YARD tags or mispelled Type names.

Show thread

Do people prefer RBS or RBI type signatures? I'm thinking of using sord to convert the YARDocs of one of my big projects into type definitions file and adding a `check` command that validates a script against the generated and vendored type defs.

So how would you test if an overrided method calls super with certain arguments which the overrided method assigns default values to? Seems like I may have to copy/paste the original specs for those methods in order to test whether the overrided arguments default values are being passed down correctly.

What's the most accurate way to measure the loaded memory footprint of a Ruby library? Is there a quick-n-dirty way to require every dependency and every file in a library to ensure everything is loaded into memory?

Should a multi-library project host multiple versions of it's library's documentation? Or only host the stable versions? Or only host stable + the pre/rc/beta version?

Context: I'm wanting to release prerelease versions of multiple libraries that are part of a large overarching project. I also want to host the documentation somewhere so beta-tests can provide feedback on it before it's officially released?

What are some ways developers make returning a value object more sexy? I feel like `return Value::SpecificValue.new(data)` is a bit too verbose. Need more syntactic sugar.

Show older

A Mastodon instance for Rubyists & friends