Skip to content

Instantly share code, notes, and snippets.

@jeffa
Last active February 13, 2017 20:41
Show Gist options
  • Select an option

  • Save jeffa/7bcce089d4be794cb8304eb514afd5d2 to your computer and use it in GitHub Desktop.

Select an option

Save jeffa/7bcce089d4be794cb8304eb514afd5d2 to your computer and use it in GitHub Desktop.
#!/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