-
Notifications
You must be signed in to change notification settings - Fork 32
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
Load subcommand plug-ins at runtime #1
Conversation
Rocking on! This is a nice implementation for the problem however there is a feature which I was interested on: the ability of inspecting the available gems and require the commands on initialization. In this way the subcommands and their description would be available on the help. Thoughts? |
@orta Lol! |
Hi @irrationalfab, TIL rubygems has a method that makes this even easier. Please check the updated PR description and the commit. This should change to |
This is looking perfect! I haven’t had time to test it yet, I will try to do that this afternoon. |
Just tested the open_pod_bay and read the patch, outstanding implementation! 🍻 Do you mind sending a pull request in CocoaPods/CocoaPods (sorry for the dance) to add the relative entry to the changelog crediting yourself? |
Quick question before you merge it, @irrationalfab. Does this work with MRI 1.8.7 and the RubyGems version that come installed on stock OS X 10.8? (And 10.9, but I assume it does there.) |
I don't have 10.8 available anymore. Now I tested it with Ruby |
Just tested it on a clean 10.8 system and it works! As a side-note, the RubyGems version that comes with 10.8 is 1.3.6, for the time being this should be our baseline. @leshill I assume that filename = "#{underscore(name)}/plugin"
files = Gem.respond_to?(:find_latest_files) ? Gem.find_latest_files(filename) : Gem.find_files(filename, true) |
@load_plugins = true | ||
end | ||
end | ||
|
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.
Can you make underscore
private and add a link to ActiveSupport’s LICENSE file?
Hi @alloy @irrationalfab, Changes made. I removed the memoization as it was not necessary. I will make a PR on CocoaPods as well. |
We use rubygems to load a subcommand plug-in gem with a file that can be loaded at <command-path>/plugin.rb The `command-path` is the namespace of the command converted to a path. For example `Pod::Command` becomes `pod/command`. The `plugin.rb` file should either define the subcommand(s) directly or require the files for the subcommand(s). For example [open_pod_bay](https://github.com/leshill/open_pod_bay) has the following `plugin.rb` require 'pod/command/open'
Thanks for the changes, it looks good! Time to merge and play with it a bit before releasing (either tomorrow or Friday). |
Load subcommand plug-ins at runtime
Really excited about this being merged! |
Hi @irrationalfab, Done. Take a look at #3 . |
👍 Looks great! |
We use rubygems to load a subcommand plug-in gem with a file that can be loaded at
The
command-path
is the namespace of the command converted to a path. For examplePod::Command
becomespod/command
.The
plugin.rb
file should either define the subcommand(s) directly or require the files for the subcommand(s). For example, the first working plugin, open_pod_bay, provides anopen
subcommand and has the followingplugin.rb
gem install open_pod_bay
to try it with this PR.