We are going to fix the situation by using nodenv capabilities with npx wrapper and use env variable to select desired nodejs version whenever we need it, default local version will stay 14, on demand we select 22.
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
module CalculatableAttributes | |
extend ActiveSupport::Concern | |
class_methods do | |
def calculate(attribute, &block) | |
attr_name = attribute.to_s.delete("?") | |
attr_block = block | |
@@calculate_methods ||= {} | |
@@calculate_methods[name] ||= {} |
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
namespace :active_admin do | |
desc "Build Active Admin Tailwind stylesheets" | |
task build: :environment do | |
command = [ | |
Rails.root.join("bin/tailwindcss").to_s, | |
"-i", Rails.root.join("app/assets/stylesheets/active_admin.tailwind.css").to_s, | |
"-o", Rails.root.join("app/assets/builds/active_admin.css").to_s, | |
"-m" | |
] |
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
#!/usr/bin/env ruby | |
tag_prefix = "version/" | |
changelog_path = "CHANGELOG.md" | |
changelog = File.read(changelog_path) | |
if changelog.empty? | |
puts "No changelog found in #{changelog_path}" | |
exit | |
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
require "amazing_print" | |
class Debug | |
def self.print_message(message, output_path: nil) | |
if output_path | |
File.open(output_path, "a") do |file| | |
file.puts(message) | |
end | |
else | |
ap(message) | |
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
require "amazing_print" | |
class Debug | |
def self.trace(with_sql: false) | |
if with_sql | |
subscriber = ActiveSupport::Notifications.subscribe("sql.active_record") do |event| | |
payload = event.payload[:sql] | |
next if payload.match?(/^(SELECT|SET|SHOW|BEGIN|COMMIT|ROLLBACK|RELEASE|SAVEPOINT)/) | |
# next if payload.include?("audits") | |
event.payload[:type_casted_binds].each_with_index do |bind, index| |
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
it "does something" do | |
log_sql do | |
request | |
expect(create_call).to_not raise_exception | |
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
require "rails_helper" | |
require "stringio" | |
require "json" | |
RSpec.describe API do | |
include Rack::Test::Methods | |
def app | |
API | |
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
require "amazing_print" | |
AmazingPrint.pry! | |
app_id = | |
ENV["APP_ID"].presence || | |
Rails.application.class.name.deconstantize.parameterize | |
app_env = ENV["ENVIRONMENT"].presence || Rails.env | |
commit_sha = ENV["GIT_COMMIT_SHA"]&.slice(0, 7) | |
commit_sha = `git rev-parse --short HEAD`.strip unless Rails.env.production? |
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 SolidQueueAliveServer | |
def initialize(host: nil, port: nil, engine: nil, logger: nil) | |
@host = host || "0.0.0.0" | |
@port = port || 7433 | |
@engine = engine || "puma" | |
@logger = logger || Rails.logger | |
end | |
def run! | |
require "rackup" |
NewerOlder