Last active
February 13, 2017 20:41
-
-
Save jeffa/7bcce089d4be794cb8304eb514afd5d2 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
| #!/usr/bin/env ruby | |
| limit = 2 | |
| key = 'none' | |
| message = File.read( ARGV[0] ) | |
| tokens = message.split() | |
| buckets = { 'what' => [], 'why' => [], key => [] } | |
| tokens.each do |token| | |
| t = token.downcase | |
| if t == 'what:' or t == 'why:' | |
| key = t.chomp( ':' ) | |
| else | |
| buckets[key].push( token ) | |
| end | |
| end | |
| if buckets['what'].length < limit or buckets['why'].length < limit | |
| puts "[POLICY] Your message is not sufficiently meaningful" | |
| exit 1 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment