Created
April 22, 2011 07:02
-
-
Save epitron/936196 to your computer and use it in GitHub Desktop.
possible pry plugin parameterization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# The result is an anonymous module (named "name") that can be mixed into the | |
# Commands class. | |
# | |
Pry.plugin "name" do | |
## Settings | |
settings do | |
bool :make_awesome, :default => true | |
int :max_goats, :default => proc { maximum_goat_memory } | |
enum :goat_type, :default => "plain", :options => %w[ plain mountain billy ] | |
string :favorite_goat, :default => "Super Dave the Goat", :validate => proc { goat[/super/i] } | |
time :expire_goats, :default => 5.minutes | |
end | |
## Helpers | |
def helper | |
"I HELP GOATS" | |
end | |
## Commands | |
command "help_a_goat" do |arg| | |
output.puts helper | |
end | |
command "add_goat" do |arg| | |
@goats ||= [] | |
raise InvalidGoatError if @goats.size > settings.max_goats | |
@goats << Goat.new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment