-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.rb
33 lines (27 loc) · 946 Bytes
/
check.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
28
29
30
31
32
33
require 'nokogiri'
require 'yaml'
$input_file=ARGV[0]
doc = Nokogiri::HTML(open($input_file))
lib_version_hash={}
puts "processin deps"
doc.css('table.deps tbody')[0].css('tr').each {|tr|
lib_name = tr.css('td')[0].css('a')[0]['href']
puts lib_name
lib_version = tr.css('td')[1].css('a')[0].content
# if lib_version_hash.has_key? lib_name then
# puts "already existed #{lib_name} #{lib_version_hash[lib_name]} => #{lib_version}"
# end
lib_version_hash[lib_name]=lib_version
}
#puts lib_version_hash
#puts lib_version_hash.size
puts "processing conflicts"
# setting from conflicts list
doc.css('table.conflicts tbody')[0].css('tr').each { |tr|
lib_name = tr.css('td')[0].css('a')[0]['href']
selected_version = tr.css('td')[1].css('a')[0].content
lib_version_hash[lib_name]=selected_version
}
puts lib_version_hash
puts lib_version_hash.size
File.open($input_file+".yml","w"){|f| f.write(lib_version_hash.to_yaml)}