Skip to content

Commit

Permalink
get it working
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpeterson committed Oct 21, 2024
1 parent 2ca53e5 commit cbd613b
Show file tree
Hide file tree
Showing 15 changed files with 351 additions and 68 deletions.
240 changes: 240 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
PATH
remote: .
specs:
patch_me_in (0.1.0)
rails (>= 8.0.0.beta1)

GEM
remote: https://rubygems.org/
specs:
actioncable (8.0.0.beta1)
actionpack (= 8.0.0.beta1)
activesupport (= 8.0.0.beta1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (8.0.0.beta1)
actionpack (= 8.0.0.beta1)
activejob (= 8.0.0.beta1)
activerecord (= 8.0.0.beta1)
activestorage (= 8.0.0.beta1)
activesupport (= 8.0.0.beta1)
mail (>= 2.8.0)
actionmailer (8.0.0.beta1)
actionpack (= 8.0.0.beta1)
actionview (= 8.0.0.beta1)
activejob (= 8.0.0.beta1)
activesupport (= 8.0.0.beta1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (8.0.0.beta1)
actionview (= 8.0.0.beta1)
activesupport (= 8.0.0.beta1)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (8.0.0.beta1)
actionpack (= 8.0.0.beta1)
activerecord (= 8.0.0.beta1)
activestorage (= 8.0.0.beta1)
activesupport (= 8.0.0.beta1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (8.0.0.beta1)
activesupport (= 8.0.0.beta1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (8.0.0.beta1)
activesupport (= 8.0.0.beta1)
globalid (>= 0.3.6)
activemodel (8.0.0.beta1)
activesupport (= 8.0.0.beta1)
activerecord (8.0.0.beta1)
activemodel (= 8.0.0.beta1)
activesupport (= 8.0.0.beta1)
timeout (>= 0.4.0)
activestorage (8.0.0.beta1)
actionpack (= 8.0.0.beta1)
activejob (= 8.0.0.beta1)
activerecord (= 8.0.0.beta1)
activesupport (= 8.0.0.beta1)
marcel (~> 1.0)
activesupport (8.0.0.beta1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.3.0)
bigdecimal (3.1.8)
builder (3.3.0)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.4)
drb (2.2.1)
erubi (1.13.0)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.2)
language_server-protocol (3.17.0.3)
logger (1.6.1)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.4)
mini_mime (1.1.5)
minitest (5.25.1)
net-imap (0.5.0)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
propshaft (1.1.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
rack
railties (>= 7.0.0)
psych (5.1.2)
stringio
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.1.7)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (8.0.0.beta1)
actioncable (= 8.0.0.beta1)
actionmailbox (= 8.0.0.beta1)
actionmailer (= 8.0.0.beta1)
actionpack (= 8.0.0.beta1)
actiontext (= 8.0.0.beta1)
actionview (= 8.0.0.beta1)
activejob (= 8.0.0.beta1)
activemodel (= 8.0.0.beta1)
activerecord (= 8.0.0.beta1)
activestorage (= 8.0.0.beta1)
activesupport (= 8.0.0.beta1)
bundler (>= 1.15.0)
railties (= 8.0.0.beta1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (8.0.0.beta1)
actionpack (= 8.0.0.beta1)
activesupport (= 8.0.0.beta1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rdoc (6.7.0)
psych (>= 4.0.0)
regexp_parser (2.9.2)
reline (0.5.10)
io-console (~> 0.5)
rubocop (1.66.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-minitest (0.36.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.22.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.26.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails-omakase (1.0.0)
rubocop
rubocop-minitest
rubocop-performance
rubocop-rails
ruby-progressbar (1.13.0)
securerandom (0.3.1)
sqlite3 (2.1.0-arm64-darwin)
stringio (3.1.1)
thor (1.3.2)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (0.13.1)
useragent (0.16.10)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.18)

PLATFORMS
arm64-darwin

DEPENDENCIES
patch_me_in!
propshaft
puma
rubocop-rails-omakase
sqlite3

BUNDLED WITH
2.5.21
8 changes: 8 additions & 0 deletions lib/generators/patch_me_in/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Description:
Explain the generator

Example:
bin/rails generate patch Thing

This will create:
what/will/it/create
7 changes: 7 additions & 0 deletions lib/generators/patch_me_in/patch_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class PatchGenerator < Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)

def create_patch_file
template "patch.tt", "app/patches/#{file_name}_patch.rb"
end
end
6 changes: 6 additions & 0 deletions lib/generators/patch_me_in/templates/patch.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module <%= class_name %>Patch
include PatchMeIn::Base

def some_new_method
end
end
6 changes: 0 additions & 6 deletions lib/patch.rb

This file was deleted.

21 changes: 0 additions & 21 deletions lib/patch/base.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/patch/engine.rb

This file was deleted.

6 changes: 6 additions & 0 deletions lib/patch_me_in.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require "patch_me_in/base"
require "patch_me_in/version"
require "patch_me_in/engine"

module PatchMeIn
end
30 changes: 30 additions & 0 deletions lib/patch_me_in/base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module PatchMeIn
module Base
extend ActiveSupport::Concern

included do
extend ActiveSupport::Concern
@@patches = nil
end

class_methods do
def patches(name)
name = name.name if name.is_a?(Module)
@@patches = name
end

def patched_name
@@patches || name.sub(/Patch$/, "")
end

def patched_module
patched_name.constantize
end

def apply!
puts "Applying #{patched_name} to #{self}"
patched_module.tap { _1.include self }
end
end
end
end
14 changes: 14 additions & 0 deletions lib/patch_me_in/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module PatchMeIn
class Engine < ::Rails::Engine
isolate_namespace PatchMeIn

initializer "patch_me_in.reloader" do |app|
app.reloader.to_prepare do
Dir.glob("**/*.rb", base: app.root / "app/patches") do |name|
puts "Patching #{name}"
name.sub(/\.rb$/, "").camelize.constantize.apply!
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/patch/version.rb → lib/patch_me_in/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Patch
module PatchMeIn
VERSION = "0.1.0"
end
26 changes: 0 additions & 26 deletions patch.gemspec

This file was deleted.

Loading

0 comments on commit cbd613b

Please sign in to comment.