danielharan (owner)

Revisions

gist: 16048 Download_button fork
public
Public Clone URL: git://gist.github.com/16048.git
Embed All Files: show embed
edid_to_names.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class String
  def starts_with?(str)
    self =~ /#{str}/
  end
end
 
names_to_edid = File.open(File.dirname(__FILE__) + '/edid_names').read.split("\n").
  collect {|line| edid, pruid, edname = line.split("|"); [edname.strip, edid.strip]}.
  inject({}) {|hash,e| hash[e.first] = e.last; hash }
 
lines = File.open(ARGV[0]).read.split("\n").inject({}) {|hash,e| pc, rest = e.split(','); hash[pc] = rest; hash}
 
lines.reject! {|k,v| v.nil?}
 
lines.each do |k,v|
  if v =~ /^[^a-z]*$/
    puts "#{k},#{v}"
  else
    begin
    edid = names_to_edid.detect {|name,edid| name.starts_with?(v)}.last
    puts k + "," + edid
    rescue
      puts "oops on [#{k},#{v}]"
    end
  end
end