Created
January 9, 2015 19:08
-
-
Save compwron/a64972f2e3c527405923 to your computer and use it in GitHub Desktop.
alpha params finder
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
| filename = ARGV[0] || 'app/models/transaction.rb' | |
| f = File.open(filename, 'rb') | |
| c = f.read | |
| all = c.split(/\n|,/).map { |i| i.strip.gsub(/[^A-Za-z0-9\s\[\]\._\(\)]/, '') }.reject(&:empty?) | |
| # too many false positives | |
| DEFAULT = 'aaa --- DEFAULT --- ' | |
| alph_list = [DEFAULT] | |
| all.each do |line| | |
| if [alph_list.last, line].sort.last == line # this line is after everything in alph list alphabetically | |
| alph_list << line | |
| else | |
| if alph_list.size > (ARGV[1].to_i || 6) | |
| puts (alph_list - [DEFAULT]).join("\n") + "\n\n" | |
| end | |
| alph_list = [DEFAULT] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment