Sha256: 9b28105aa531e8a87403e3ed6d263551c9ed14b2bd5fb094031f295d240aca01
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
#!/usr/bin/env ruby require 'concurrent' require 'stepmod/utils/stepmod_file_annotator' stepmod_dir = ARGV.first || Dir.pwd # build resource_docs cache resource_docs_cache_file = `mktemp` `"#{File.join(__dir__, 'stepmod-build-resource-docs-cache')}" "#{stepmod_dir}" > "#{resource_docs_cache_file}"` # annotate each file files = `"#{File.join(__dir__, 'stepmod-find-express-files')}" "#{stepmod_dir}"`.strip.split("\n") MAX_THREADS = [2, Concurrent.processor_count].max * 2 MAX_QUEUE_SIZE = MAX_THREADS * 4 # https://github.com/ruby-concurrency/concurrent-ruby/blob/master/docs-source/thread_pools.md pool = Concurrent::ThreadPoolExecutor.new( :min_threads => MAX_THREADS, :max_threads => MAX_THREADS, :max_queue => MAX_QUEUE_SIZE, :fallback_policy => :caller_runs ) files.each_slice(MAX_QUEUE_SIZE) do |batch| puts("Queueing next batch") batch.each do |file| pool.post do puts("Queued processing #{file}") annotated = Stepmod::Utils::StepmodFileAnnotator.new(express_file: file, resource_docs_cache_file: resource_docs_cache_file, stepmod_dir: stepmod_dir).call File.open(File.join(File.dirname(file), "#{File.basename(file, '.exp')}_annotated.exp"), 'w') do |file| file.puts(annotated) end puts("Done processing #{file}") end end pool.shutdown end # cleanup `rm "#{resource_docs_cache_file}"`
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stepmod-utils-0.2.4 | exe/stepmod-annotate-all |
stepmod-utils-0.2.3 | exe/stepmod-annotate-all |