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
Making pod plugins
an abstract command with search as default subcommand
#13
Conversation
…th `search` as the default command (#12)
|
||
it 'should download the default template repository' do | ||
@command = create_command(argv('cocoapods-banana')) | ||
# @command = Command::Plugins::Create.new(argv("cocoapods-banana")) |
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.
Let's not leave commented-out code
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.
😲 where does this line come from ?!
Agreed.
BTW feel free to add some more specs if you see some use cases I may have forgotten.
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.
BTW, as a ruby newbie, I was wondering: what are the naming conventions regarding test labels?
- should we always start the test name with
should …
to have some consistency, namely should I refactor specs always usingit 'should XXX' do
? - or is it not such a big deal and is it ok (naming-convention-wise) to keep labels such as
it 'prints out all plugins when no query passed' do
orit 'registers itself' do
?
I suspect that every test label should start with should
to make the spec more english-like and readable, but the initial cocoapods-plugins
specs by @dbgrandi didn't respect this convention so I'm wondering 😉
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.
@AliSoftware I think that the quoted part of the test should make and english sentence when read inline with the it
method and should be as short a possible. For example I prefer:
it 'prints something'
to
it 'should print something'
as the should is just white-noise as it doesn't convey any additional information.
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.
Ok, I guess there is no real convention after all.
I often saw it 'should ...'
but am ok with keeping the label short, as long as we are… yeah you guessed it… consistent 😆 across all CP code 😉
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.
😄
New commit available which:
|
(see discussion in #11)
New refactoring available, guys!
This should match the decisions we took in discussions #11 and #12 Note: code review welcome, especially about:
|
PS: @dbgrandi @irrationalfab If you guys feel like the code is ok, maybe we could merge this by now, and close #10, #11 & #12 ? (and even maybe publish 0.1.1)? |
end | ||
# Add this as an extension into the Search and List specs to help stub the plugins.json request | ||
module PluginsStubs | ||
require File.expand_path '../lib/pod/plugins_helper', File.dirname(__FILE__) |
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.
This should not be needed as plugins_helper
should already be loaded from the require 'cocoapods_plugin'
above.
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.
This should not be needed as plugins_helper should already be loaded from the require 'cocoapods_plugin' above.
You're right. Will fix it right away.
FYI, I added this line in an attempt to fix an issue I had when previously referencing PluginsHelper::PLUGINS_URL
two lines below instead of Pod::PluginsHelper::PLUGINS_URL
.
Ruby was then unable to resolve the PluginsHelper
constant, trying to resolve it as SpecHelper::PluginsStubs::PluginsHelper::PLUGINS_URL
instead of the expected value. By the time I realized I just had to use Pod::PluginsHelper::PLUGINS_URL
instead of just PluginsHelper::PLUGINS_URL
to make it work, I forgot to remove this require
statement that was an attempt to fix this constant resolution issue I had 😉
@AliSoftware Ace job! This PR is starting to encompass multiple issues, so 👍 on getting this merged in. Only feedback I have here is that I'd move the Using the standard Use the more specific
|
Actually I hesitated about where I should put those files in the first place. Do you suggest that, in addition to moving them in the |
That's what I understood from the rdocs, so why do we sometimes write Is the |
Ok that's what I guessed and why I wrote |
DESC | ||
|
||
def self.options | ||
super.reject { |option, _| option == '--silent' } |
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.
It might make sense to port this logic to CLAide /c @alloy
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.
Not sure, it’s quite simple to grasp if you know Ruby. What would you propose?
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.
@Allow I agree that this is pretty annoying to have to .concat(super).reject { }
every time we create a subcommand (to get the common options like --verbose
and --help
and all with Array#concat(super)
… but except some like --silent
in some cases with Array#reject
)
Maybe we can have helper methods in Pod::Command
if not in CLAide::Command
, like self.common_options
(even with some parameter to handle multiple cases like commands designated to only output stuff and do nothing else, for which options like --silent
wouldn't have much sense), so that we could Array#concat
with this instead of super
?
At least I'm sure it's worth thinking about sthg to avoid this concat
+reject
pattern that we observe in a lot of pod subcommands.
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.
I think it’s definitely worth it to create a CLAide ticket about it to remind us to reflect on this in the future.
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.
@alloy @irrationalfab Ticket opened!
Looks good to me 👍 for the merge! |
Some lines are too long but that is another issue: #17. |
@AliSoftware ⭐ 🌟 🎆 As your help with the issues has been invaluable I granted push access to you... just use this power wisely by asking via a pull request if you are unsure about a change. To celebrate I will let to you the pleasure to push the green button. Great work! /c @CocoaPods/owners |
Yes
To save space/time. These are equivalent.
If you do a search across the main cocoapods project, you'll find that any case where a raw |
Yay! \o/ |
Making `pod plugins` an abstract command with list as default subcommand
🍻 |
🍻 |
Fully agreed! |
Thx guys 🍻 |
pod plugins
is now an abstract command (fixes Refactor Plugins as an abstract command #11)[EDIT] See below, now the newsearch
is now the default subcommand (fixes Makesearch
the default subcommand #12) and accepts an empty query (making it list all the plugins)list
subcommand is the default oneplugins.rb
into one command class per file #10)