Created
April 26, 2011 02:46
-
-
Save epitron/941702 to your computer and use it in GitHub Desktop.
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
# | |
# Creates a new CommandSet and automatically mixes it into Pry::Commands. | |
# | |
Pry.plugin :test do | |
settings do | |
bool :make_awesome, :default => true | |
enum :goat_type, :default => "plain", :options => %w[ plain mountain billy ] | |
string :favorite_goat, :default => "Super Dave the Goat", :validate => proc { goat[/super/i] } | |
int :expire_goats, :default => 5.minutes | |
end | |
helpers do | |
def helper | |
"I HELP GOATS" | |
end | |
end | |
command "help-a-goat" do | |
output.puts helper | |
end | |
# A stand-alone setting (to keep related things grouped together) | |
setting :max_goats, :default => proc { free_memory / goat_size } | |
command "add-goat" do |arg| | |
@goats ||= [] | |
raise InvalidGoatError if @goats.size > settings.max_goats | |
@goats << Goat.new(arg) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment