Software Development |
Ruby on Rails
Highline Gem
James Gray's highline is one of the Ruby Gems used in altered_beast.
Highline is a system for data entry from the command line, including the appropriate validation and type conversion. The main methods are say, ask, agree, and choose.
Altered_beast uses highline functionality in the app_bootstrap plugin to get input of configuration items via the console. This all happens in vendor/plugins/app_bootstrap/tasks/app_bootstrap.rake.
For example, this code uses the methods highline say and agree to check whether the developer wants to overwrite their existing database.yml file with an automatically generated one:
vendor/plugins/app_bootstrap/tasks/app_bootstrap.rake (snippet)
db_config = "config/database.yml"
db_config = File.readlink(db_config) if File.symlink?(db_config)
if File.exist?(db_config)
say "It looks like you already have a database.yml file."
@restart = agree("Would you like to CLEAR it and start over? [y/n]")
end
