Skip to content

Instantly share code, notes, and snippets.

View jcouball's full-sized avatar
👍

James Couball jcouball

👍
  • Yahoo
  • Temecula, CA
View GitHub Profile

AI Policy

Reviewing and maintaining code requires human insight. While AI tools can be helpful assistants, they are no substitute for human judgment and creativity.

We value the unique perspectives and critical thinking that our contributors bring. If you use AI tools to assist your work:

  1. You are responsible: You must review and understand every line of code or text you submit.
@jcouball
jcouball / gist:c3250965aeb087d31d5bad70409415a8
Created July 8, 2025 18:58
Running RSpec to execute Gherkin and "normal" RSpec tests
$ rspec --format=documentation  ✔
Defining a command line parser
It calls the set_defaults method if defined
Given a class named "CommandLine" which derives from "CommandLineBoss" -> Given a class named "CommandLine" which derives from "CommandLineBoss" with the body -> When an instance of the "CommandLine" class is created -> Then the "set_defaults" method should have been called
It defines the instance attributes and sets the default_values
Given a class named "CommandLine" which derives from "CommandLineBoss" -> Given a class named "CommandLine" which derives from "CommandLineBoss" with the body -> When an instance of the "CommandLine" class is created -> Then the "users" attribute should eq "[]" -> And the "verbose" attribute should eq "false"
It calls the private define_*_option methods defined in the "CommandLine" class
Given a class named "CommandLine" which derives from "CommandLineBoss" -

Default Branch Name Change

It's becoming increasingly common for Git repositories to rename their default branch from master to main. If you've cloned or forked a repository that has made this change, you'll need to update your local copy to reflect it. Here are the steps to do so.

For a Cloned Repository

If you have NO local changes

If your local master branch has no new commits you need to keep, the process is straightforward.

require 'delegate'
class LoggingDelegator < SimpleDelegator
def initialize(target, logger = Logger.new($stdout, level: Logger::INFO))
super(target)
@logger = logger
end
def method_missing(method, *args, &block)
logger.info { "> #{__getobj__.class}##{method}(#{args.map(&:inspect).join(', ')})" }
# Like a simple delegator that logs methods called on the target
#
# @example
# logger = Logger.new($stdout, level: Logger::INFO)
# target = SomeClass.new
# logger = MethodLogger.new(target, logger)
# target.some_method(arg1, arg2)
# # Logs:
# # > some_method(arg1, arg2)
# # < some_method(arg1, arg2) returning return_value

Design Philosophy of the git Gem

The git gem is designed to be a thin wrapper around the Git command line, providing a simple and intuitive interface for Ruby developers to programmatically interact with Git.

Key Features

Direct Mapping to Git Commands

  • Each method on a Git::Base object (the object returned by Git.open, Git.clone, or
@jcouball
jcouball / testing_ruby_kernel_exit.adoc
Last active March 11, 2024 22:29
Testing Ruby code that calls `abort` and `exit`

Testing Ruby code that calls abort and exit

Testing code that uses the abort or exit is a challenge for many developers. These methods are often used in command-line applications to terminate the program early and return an exit status to the operating system. Developers often encounter conflicting opinions and misleading advice when seeking clear guidance on this topic.

This article demystifies the testing of such code, offering a simple and

@jcouball
jcouball / rubyconf-2023.schedule.json
Created November 30, 2023 02:01
RubyConf 2023 Schedule
{
"sessions": [
{
"id": "dcfadcec-5674-4146-8b62-f9f04ce157b1",
"title": "Morning Coffee and Pastries - 8:30 - 10:00 AM",
"description": "Start your day with coffee (regular/decaffe), herbal tea, juices, seasonal fruit, and bakery selections.",
"startsAt": "2023-11-13T08:30:00",
"endsAt": "2023-11-13T10:00:00",
"isServiceSession": true,
"isPlenumSession": true,
@jcouball
jcouball / semver.rb
Last active March 10, 2023 16:28
Ruby Semver Regexp
SEMVER_REGEXP = /
^
(?<major>0|[1-9]\d*)
\.
(?<minor>0|[1-9]\d*)
\.
(?<patch>0|[1-9]\d*)
(?:-
(?<prerelease>
(?: