Skip to content

Instantly share code, notes, and snippets.

@ginkouno
Last active August 29, 2015 13:58
Show Gist options
  • Save ginkouno/9970679 to your computer and use it in GitHub Desktop.
Save ginkouno/9970679 to your computer and use it in GitHub Desktop.
poi server(?)をdaemonとして起動する
#!/usr/bin/env ruby
require 'bundler/setup'
Bundler.require
# SpponDaemon can accept options :pid_dir, :name.
# Please read ->https://github.com/etaque/spoon_daemon
if ["start", "stop", "restart"].index(ARGV[0])
SpoonDaemon::Runner.new('./server.rb', ARGV[0])
else
puts "Usage:daemonize.rb [start|stop|restart]"
end
source "https://rubygems.org"
gem "jruby-poi", github: "kameeoze/jruby-poi", require: "poi"
gem "spoon_daemon"
gem "pry"
gem "bundler", require: ['drb/drb', 'stringio']
#!/usr/bin/env ruby
require "bundler/setup"
Bundler.require
class Excel
def password=(password)
org.apache.poi.hssf.record.crypto.Biff8EncryptionKey.setCurrentUserPassword(password)
end
def workbook(string)
POI::Workbook.open(StringIO.new(string, 'r'))
end
end
DRb.start_service("druby://localhost:3999", Excel.new)
puts DRb.uri
loop do
sleep(5)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment