This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # config/initializers/route_format.rb | |
| # | |
| # Global route formatting override for Rails routing. | |
| # | |
| # This hooks into ActionDispatch::Routing::Mapper::Mapping and mutates the | |
| # Journey AST in place so that underscored literal path segments are | |
| # dasherized. It affects *all* routes (get, resources, scope, etc.) | |
| # because they all end up as a Journey AST passed into Mapping. | |
| # | |
| # IMPORTANT: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile do | |
| source "https://rubygems.org" | |
| gem "phlex" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BlogPost < Component::Base | |
| def view_template | |
| yield | |
| end | |
| def header(&content) | |
| h1(&content) | |
| end | |
| def post(&content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pty' | |
| require 'io/console' | |
| require 'logger' | |
| class REPL | |
| attr_reader :stdout, :stdin, :logger | |
| # Number of bytes to read at a time. | |
| READ_CHUNK_SIZE = 512 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # config/initializers/phlex_template_handler.rb | |
| require "action_view" | |
| require "phlex" | |
| # Intercept unknown "capitalized" method calls (e.g., PageView(...)) in templates, | |
| # look up a Phlex component class, instantiate it, and render it. | |
| # Crucially, we re-bind the user’s block so that `self` is the component, not the ActionView context. | |
| module PhlexDynamicMethodCalls | |
| def method_missing(name, *args, **kwargs, &block) | |
| # Only intercept method calls starting with an uppercase letter (e.g. "PageView", "MyComponent", etc.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'bundler/inline' | |
| gemfile do | |
| source 'https://rubygems.org' | |
| gem 'rspec' | |
| end | |
| require 'rspec/autorun' | |
| class Scope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Component | |
| attr_writer :post | |
| def initialize(session:, fun: "bags", deeze:) | |
| @session = session | |
| @fun = fun # Make sure we assign this, otherwise @fun would be nil | |
| @deeze = deeze | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Stop the PostgreSQL service | |
| echo "Stopping PostgreSQL service..." | |
| brew services stop postgresql || echo "PostgreSQL service not running." | |
| # Uninstall PostgreSQL | |
| echo "Uninstalling PostgreSQL..." | |
| brew uninstall --force postgresql postgresql@14 postgresql@13 || echo "PostgreSQL not installed." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "pathname" | |
| require "bundler" | |
| path = Pathname.new("/Users/bradgessler/Projects/terminalwire/traveling-ruby/shared/gemfiles/20241122") | |
| definition = Bundler::Definition.build(path.join("Gemfile"), path.join("Gemfile.lock"), nil) | |
| definition.locked_gems.specs.each do |spec| | |
| p spec.name, spec.version | |
| puts "gem install --platform=ruby #{spec.name} -v '#{spec.version}'" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # If you prefer TrueClass and FalseClass returns for predicate methods, | |
| # you can `include Boolean::Truther` into your class to automatically generate | |
| # ¿-prefixed methods that return true or false. | |
| # Define a module to automatically generate the ¿-prefixed methods | |
| module Boolean | |
| module Truther | |
| def self.included(base) | |
| base.extend(ClassMethods) | |
| end |
NewerOlder