module Pangrid
Write puzzles out in Excel's .xslx format
Useful primarily for importing a grid into a google spreadsheet for online, collaborative solving
provides:
ExcelXSLX : write
Exolve (github.com/viresh-ratnakar/exolve) is a browser-based crossword solver that allows you to embed the crossword and solving software in a single HTML file.
Qxw
savefile for rectangular grids [www.quinapalus.com/qxw.html]
Markup used by crosswords.reddit.com
Plain text representation
Mostly used for debugging and quick printing of a grid right now, but it would be useful to have a minimalist text representation of a grid and clues.
provides:
Text : write
Constants
- FILL_CHARS
- GRID_CHARS
- QXW_GRID_ERROR
- TEMPLATE
- TEMPLATE_DIR
- VERSION
Public Class Methods
require_for_plugin(name, gems)
click to toggle source
Load all the gem dependencies of a plugin
# File lib/pangrid/plugin.rb, line 15 def self.require_for_plugin(name, gems) missing = [] gems.each do |gem| begin require gem rescue LoadError => e # If requiring a gem raises something other than LoadError let it # propagate upwards. missing << gem end end if !missing.empty? raise PluginDependencyError.new(name, missing) end end
run(opts)
click to toggle source
# File lib/pangrid.rb, line 33 def self.run(opts) Plugin.load_all if opts[:list] Plugin.list_all return end # run the converter # from = Plugin.get(opts[:from]) to = Plugin.get(opts[:to]) if !from or !from.method_defined? :read $stderr.puts "No reader for #{opts[:from]}" return end if !to or !to.method_defined? :write $stderr.puts "No writer for #{opts[:to]}" return end if !File.exist? opts[:in] $stderr.puts "Cannot find file #{opts[:in]}" return end reader = from.new writer = to.new input = IO.read(opts[:in]) output = writer.write(reader.read(input)) File.open(opts[:out], "w") do |f| f.print output end end
run_command_line()
click to toggle source
# File lib/pangrid.rb, line 8 def self.run_command_line # command line options p = Trollop::Parser.new do version "pangrid #{VERSION}" opt :from, "Format to convert from", :type => :string opt :to, "Format to convert to", :type => :string opt :in, "Input file", :type => :string opt :out, "Output file", :type => :string opt :list, "List available format plugins" opt :web, "Launch webserver" end Trollop::with_standard_exception_handling p do opts = p.parse ARGV if opts[:web] run_webserver 1234 elsif opts[:list] || [:from, :to, :in, :out].all? {|k| opts[k]} run opts else p.educate end end end
run_webserver(port)
click to toggle source
# File lib/pangrid/frontend/webrick.rb, line 56 def self.run_webserver(port) puts "-------------------------------------------" puts "Open your web browser and load" puts " http://localhost:#{port}" puts "-------------------------------------------" Plugin.load_all logfile = File.open('pangrid-webrick-access.log', 'a') logfile.sync = true log = [ [logfile, WEBrick::AccessLog::COMMON_LOG_FORMAT] ] server = WEBrick::HTTPServer.new(:Port => port, :AccessLog => log) server.mount "/", Servlet trap("INT") { server.shutdown } server.start end