module Bboxer
Constants
- JAVASCRIPTS
- VERSION
Public Class Methods
process_file(path)
click to toggle source
# File lib/bboxer.rb, line 58 def process_file(path) page.visit(path) # page.save_screenshot("pre.png", { full: true }) # inject scripts into page and run page.execute_script(JAVASCRIPTS) # page.save_screenshot("post.png", { full: true }) return page.body end
process_path(path)
click to toggle source
# File lib/bboxer.rb, line 30 def process_path(path) expanded_path = File.expand_path(path) if File.directory?(expanded_path) Dir.entries(expanded_path).each do |entry_name| next if %w(. ..).include?(entry_name) entry_path = File.join(path, entry_name) process_path(entry_path) end elsif File.exists?(expanded_path) if path.end_with?(".svg") puts "Processing: #{path}" output_path = expanded_path.sub(/\.svg$/, "-updated.svg") time = Benchmark.measure do document = process_file(expanded_path) File.open(output_path, "w") { |f| f.write(document) } end puts "Finished in #{time.real.round(3)}ms" puts "Output written to #{output_path}" else puts "Ignoring file: #{expanded_path}" end else puts "No such file or directory: #{expanded_path}" end end
run(args)
click to toggle source
# File lib/bboxer.rb, line 24 def run(args) args.each do |arg| process_path(arg) end end