| 
									
										
										
										
											2016-09-08 09:05:00 +01:00
										 |  |  | #: @hide_from_man_page | 
					
						
							|  |  |  | #:  * `aspell_dictionaries`: | 
					
						
							|  |  |  | #:    Generates the new dictionaries for the `aspell` formula. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | require "open-uri" | 
					
						
							|  |  |  | require "resource" | 
					
						
							|  |  |  | require "formula" | 
					
						
							| 
									
										
										
										
											2014-09-20 14:33:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-20 14:33:59 +01:00
										 |  |  |   def aspell_dictionaries | 
					
						
							| 
									
										
										
										
											2017-03-12 19:44:01 +00:00
										 |  |  |     dict_url    = "https://ftpmirror.gnu.org/aspell/dict" | 
					
						
							| 
									
										
										
										
											2015-01-04 05:02:27 +01:00
										 |  |  |     dict_mirror = "https://ftp.gnu.org/gnu/aspell/dict" | 
					
						
							| 
									
										
										
										
											2014-09-20 14:33:59 +01:00
										 |  |  |     languages   = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     open("#{dict_url}/0index.html") do |content| | 
					
						
							|  |  |  |       content.each_line do |line| | 
					
						
							| 
									
										
										
										
											2016-09-11 17:41:51 +01:00
										 |  |  |         break if %r{^</table} =~ line | 
					
						
							|  |  |  |         next unless /^<tr><td><a/ =~ line | 
					
						
							| 
									
										
										
										
											2014-09-20 14:33:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         fields = line.split('"') | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |         lang = fields[1] | 
					
						
							|  |  |  |         path = fields[3] | 
					
						
							| 
									
										
										
										
											2015-08-06 15:45:52 +08:00
										 |  |  |         lang.tr!("-", "_") | 
					
						
							| 
									
										
										
										
											2014-09-20 14:33:59 +01:00
										 |  |  |         languages[lang] = path | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     languages.inject([]) do |resources, (lang, path)| | 
					
						
							|  |  |  |       r = Resource.new(lang) | 
					
						
							|  |  |  |       r.owner = Formulary.factory("aspell") | 
					
						
							|  |  |  |       r.url "#{dict_url}/#{path}" | 
					
						
							|  |  |  |       r.mirror "#{dict_mirror}/#{path}" | 
					
						
							|  |  |  |       resources << r | 
					
						
							|  |  |  |     end.each(&:fetch).each do |r| | 
					
						
							|  |  |  |       puts <<-EOS
 | 
					
						
							| 
									
										
										
										
											2014-11-20 20:11:24 -06:00
										 |  |  |         option "with-lang-#{r.name}", "Install #{r.name} dictionary" | 
					
						
							| 
									
										
										
										
											2014-09-20 14:33:59 +01:00
										 |  |  |         resource "#{r.name}" do | 
					
						
							|  |  |  |           url "#{r.url}" | 
					
						
							|  |  |  |           mirror "#{r.mirrors.first}" | 
					
						
							| 
									
										
										
										
											2015-03-22 14:41:18 +01:00
										 |  |  |           sha256 "#{r.cached_download.sha256}" | 
					
						
							| 
									
										
										
										
											2014-09-20 14:33:59 +01:00
										 |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       EOS | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |