|
10 | 10 | COMPANY_NOT_DEFINED='not_defined' |
11 | 11 | UPDATE_NONE=0 |
12 | 12 | UPDATE_NOT_FOUND=1 |
13 | | -UPDATE_ALL=1 |
| 13 | +UPDATE_ALL=2 |
14 | 14 |
|
15 | 15 | name_mappings = YAML::load_file('./name_mappings.yml') |
16 | 16 | $companies_info = YAML::load_file('./company_infos.yml') || Hash.new(0) |
@@ -104,15 +104,24 @@ def ensure_company(companies, key, title, link) |
104 | 104 | found = false |
105 | 105 | if company_wrapper = doc.at_css('.field-name-field-organization-name') |
106 | 106 | if company_wrapper.at_css('img') |
| 107 | + company = company_wrapper.at_css('img')['alt'] |
| 108 | + else |
| 109 | + company = company_wrapper.text |
| 110 | + end |
| 111 | + if company_wrapper.at_css('a') |
107 | 112 | link = company_wrapper.at_css('a') |
108 | 113 | link['href'] = 'https://drupal.org' + link['href'] |
109 | | - html = open(link['href'], :allow_redirections => :safe) |
110 | | - company_page = Nokogiri::HTML(html) |
111 | | - if company_title = company_page.at_css('#page-subtitle') |
112 | | - company = company_title.text |
| 114 | + # If we still don't have the company name, follow the link to the page. |
| 115 | + unless company |
| 116 | + html = open(link['href'], :allow_redirections => :safe) |
| 117 | + company_page = Nokogiri::HTML(html) |
| 118 | + if company_title = company_page.at_css('#page-subtitle') |
| 119 | + company = company_title.text |
| 120 | + end |
113 | 121 | end |
114 | 122 | else |
115 | | - company = company_wrapper.text |
| 123 | + # If there is no link, use the company name instead. |
| 124 | + link = company |
116 | 125 | end |
117 | 126 | company = company.strip |
118 | 127 | company_key = company.downcase |
|
0 commit comments