Created
April 5, 2015 15:06
-
-
Save gonzalo-bulnes/f4eac16fa587b0cffd18 to your computer and use it in GitHub Desktop.
Add validation of an app.json file to a Ruby test suite (by defining a Rake task).
This file contains 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
# Rakefile | |
namespace :app_json do | |
desc 'Validate the app.json manifest' | |
task :validate do | |
require 'rainbow' | |
# check if the app.json validator is available | |
`which app.json` | |
if $?.exitstatus != 0 | |
abort <<-eos.gsub /^( |\t)+/, "" | |
The #{Rainbow('app.json').red} program is not available. | |
You may want to install it in order to validate the app.json file. | |
Try #{Rainbow('`npm install app.json --global`').yellow} (use `sudo` if necessary) | |
or see https://github.com/app-json/app.json for instructions. | |
eos | |
end | |
# perform validation | |
response = `app.json validate 2>&1` | |
# celebrate successful validation! | |
if response =~ /Your app.json file is valid!/ | |
puts Rainbow(response.strip).green | |
else | |
puts Rainbow(response.strip).red | |
end | |
end | |
end | |
# ... | |
# task :default => [:spec, 'blueprint:verify', 'app_json:validate'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment