-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make rails-autoscale-* gems wrappers around judoscale-*, simplify requires & gemspecs #209
Conversation
Stop messing with the load path, use the same approach `bundle gem` generated gems are using now with `require_relative`, and add the `frozen_string_literal` pragma as well.
Instead of directly requiring judoscale/* files, make it require the base judoscale-* lib file, and leave the work of requiring judoscale/* files to judoscale-* itself. This is more flexible as it allows judoscale-* to have extra code/setup if necessary (as it happens with judoscale-ruby for instance, which rails-autoscale-core is currently requiring), and might allow us to make rails-autoscale-* gems to be more like shims that depend on judoscale-* in the future.
The rails-autoscale-* gems will be shims on top of judoscale-* gems, simply depending on / requiring them going forward. We only include the rails-autoscale-* files on the gem via gemspec now, and the specific `version.rb` file for each, since that's necessary for the dependency / gemspec setup. This means the judoscale-* gems can now dictate the dependencies without us having to update both judoscale-* and rails-autoscale-* versions.
Use Ruby's `Dir` to list all files under `lib/`, and partition them based on whether they match `rails-autoscale` for each lib. In other words, the judoscale-* libs will get all files that don't match `rails-autoscale`, while the rails-autoscale-* libs will get all files that match `rails-autoscale`, which should really only be the main entry point that delegates back to the respective `judoscale-*` version. Now for rails-autoscale-* libs, the gemspec lists the matching judoscale-* library, it will only include the main lib/rails-autoscale* entrypoint file, which should simply require the respective judoscale-* file, making the rails-autoscale-* libs simpler shims that wrap the judoscale-* ones. This also simplifies the judoscale-* gemspecs to list only the lib/* files, rather than a few others that were previously included but weren't necessary. (like Gemfile, Rakefile, gemspecs.)
Let judoscale-* gemspecs define that, since the rails-autoscale-* depends on them, they'll follow/honor the same required Ruby version.
@@ -1,3 +1,3 @@ | |||
# frozen_string_literal: true | |||
|
|||
require "judoscale/delayed_job" | |||
require "judoscale-delayed_job" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require the base lib file, instead of directly requiring the inner file. This allows the judoscale lib to determine what needs to be required, and rails-autoscale will simply delegate to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this clean-up! 🧼
This simplifies our gem setup to avoid getting judoscale-* and rails-autoscale-* out of sync. This happened recently with good job: #198.
Changes:
rails-autoscale-*
depend on their respectivejudoscale-*
library, leavingjudoscale-*
handle any additional dependencies.rails-autoscale-*
, since it should honorjudoscale-*
.rails-autoscale-*
do not require therails-autoscale-core
library anymore, since it should have access to the core viajudoscale-*
->judoscale-ruby
, and the constant aliasing is there in judoscale-ruby.lib/*
files, no longer include Gemfile(s)/Rakefile/gemspec(s).rails-autoscale-*
will simply includelib/rails-autoscale-*
, and that will require the respectivejudoscale-*
lib nowjudoscale-*
will include everything underlib/*
, except files matchingrails-autoscale
lib/*
files between the two libs.