Created
June 4, 2011 02:54
-
-
Save basicxman/1007506 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 | |
| # Processes vim's rgb.txt for colour names! | |
| require 'awesome_print' | |
| def process(s) | |
| s.split(/[A-Z]{1}[a-z]+/).map { |x| x.downcase }.join("_").to_sym | |
| end | |
| data = File.read('./rgb.txt').split("\n") | |
| data.slice! 0 | |
| data.each do |line| | |
| args = line.split(/\s+/) | |
| if args.length == 4 # Anything with a space in the colour name can be ignored. | |
| rgb = [args[0].to_i, args[1].to_i, args[2].to_i] | |
| AwesomePrint::Colors.colors.each do |color| | |
| # Check if this is a valid colour. | |
| if color[1] == rgb | |
| puts "#{color[0]}: #{process(args[3])}" | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment