Require thread-gem and solve problem with visibility of variable p in convert-grammars

* The `thread`-gem is required for the script, because otherwise Ruby throws an error that `Queue` in line 259 is an uninitialized constant
* The variable `p` was previously in the same method with the status message saying `OK ‹path› ‹converted scopes›`. But `p` is now defined in load_grammars() and thus not visible when showing the OK-message in install_grammars(). This was solved by adding a path-parameter to install_grammars().
This commit is contained in:
Florian M. Schäfer
2015-01-06 22:06:55 +01:00
parent 8430f694e5
commit ab1b603c78

View File

@@ -5,6 +5,7 @@ require 'net/http'
require 'optparse' require 'optparse'
require 'plist' require 'plist'
require 'set' require 'set'
require 'thread'
require 'tmpdir' require 'tmpdir'
require 'uri' require 'uri'
require 'yaml' require 'yaml'
@@ -195,7 +196,7 @@ def load_grammars(tmp_dir, source, all_scopes)
end end
end end
def install_grammars(grammars) def install_grammars(grammars, path)
installed = [] installed = []
grammars.each do |grammar| grammars.each do |grammar|
@@ -204,7 +205,7 @@ def install_grammars(grammars)
installed << scope installed << scope
end end
$stderr.puts("OK #{p.url} (#{installed.join(', ')})") $stderr.puts("OK #{path} (#{installed.join(', ')})")
end end
def run_thread(queue, all_scopes) def run_thread(queue, all_scopes)
@@ -221,7 +222,7 @@ def run_thread(queue, all_scopes)
Dir.mkdir(dir) Dir.mkdir(dir)
grammars = load_grammars(dir, source, all_scopes) grammars = load_grammars(dir, source, all_scopes)
install_grammars(grammars) if $options[:install] install_grammars(grammars, source) if $options[:install]
end end
end end
end end