This file contains 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
module ActiveExchange | |
class Channel | |
def initialize(name:, server: ActiveExchange.server) | |
@server = server | |
@channel = name | |
@queue = Queue.new | |
@subscribe = false | |
end | |
def broadcast(message) |
This file contains 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 Wrapper | |
include Logging | |
def initialize(driver, socket) | |
@driver = driver | |
@socket = socket | |
@queue = Queue.new | |
@closed = false | |
setup_driver |
This file contains 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
TableComponent.new @items do |table| | |
# Emmits a `thead > th` with "Name" and a `tbody > td` with the name of each item. | |
table.column("Name") { _1.name } | |
# Emmits a `thead > th` with "Name" and a `tbody > td` with the name of each item. | |
table.column(:name) | |
# Emmits a `thead > th` with "Interview Times" and a `tbody > th` with the name of each item. | |
table.column("Name").th(class: "bg-read-100") { show(_1, :name) } |
This file contains 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
#!/usr/bin/env ruby | |
require 'fileutils' | |
require "active_support/all" | |
# Check for arguments | |
unless ARGV.length == 2 | |
puts "Usage: #{$PROGRAM_NAME} <original_class_name> <new_class_name>" | |
exit | |
end |
This file contains 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 "prawn" | |
gem "zeitwerk" | |
gem "matrix" | |
end |
This file contains 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 'phlex' | |
end | |
class Field < Phlex::HTML | |
def template |
This file contains 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 Foo | |
# Define the original render method | |
def render | |
puts "Foo#render" | |
end | |
end | |
module Overrides | |
def self.prepended(klass) | |
klass.alias_method :base_render, :render |
This file contains 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
module ComponentHelper | |
def component(name, *args, **kwargs, &block) | |
render componentize(name).new(*args, **kwargs), &block | |
end | |
private | |
def componentize(name) | |
"#{name.to_s.classify}Component".constantize | |
end | |
end |
This file contains 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
module Superview | |
module Helpers | |
module Links | |
# Give us some sane link helpers to work with in Phlex. They kind | |
# of mimic Rails helpers, but are "Phlexable". | |
def link_to(target = nil, method: nil, **attributes, &) | |
url = case target | |
when URI, URI::Builder::DSL | |
target.to_s | |
when NilClass |
This file contains 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 "phlex" | |
end | |
require "phlex/testing/view_helper" | |
include Phlex::Testing::ViewHelper |