Skip to content

Instantly share code, notes, and snippets.

@epitron
Created April 22, 2011 07:02
Show Gist options
  • Save epitron/936196 to your computer and use it in GitHub Desktop.
Save epitron/936196 to your computer and use it in GitHub Desktop.
possible pry plugin parameterization
#
# 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