Command adds the Command Design Pattern to any
This was based on
Hanami::Interactor, and started off as adding a direct
call on the singleton class, before that
was added to Hanami's. After working with different interactors and command-style gems, including ways to organize
units for execution and without depending on other utility classes,
command was born.
command has been taken on rubygems (but not updated since 2013), and
commando has been taken (but not updated since 2009) and the Dutch
probably not pronounceable by most people using this, I've decided to register this on the French
However, if you are using this directly from GitHub, you can continue using it as is, without renaming, as long as you
change the Gemfile line to
# Gemfile gem 'commande', require: 'command'
Add this line to your application's Gemfile:
or alternatively if you would like to refer to commande as
gem 'commande', require: 'command'
And then execute:
Or install it yourself as:
$ gem install commande
There are examples in the code and the tests. Here is a crude and basic example:
class FetchSecondInput include Commande output :fetched def call(*args) # always define call self.fetched = args.second end def valid?(*args) args.length == 2 end private attr_accessor :fetched end result = FetchSecondInput.call(42, 'gem') result.successful? # => true result.fetched # => 'gem' result = FetchSecondInput.call(42, 'gem', 'three is a crowd') result.successful? # => false result.fetched # => nil
There are some
Minitest assertions included in this library.
||passes if the command is successful?|
||passes if the command is valid|
||passes if the command has a certain error message|
After checking out the repo, run
bin/setup to install dependencies. Then, run
rake test to run the tests.
You can also run
bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install. To release a new version, update the
version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version,
push git commits and tags, and push the
.gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at SleeplessByte/commmand. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Shrine::ConfigurableStorage project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.