Backgroundrb最新
最新のbackgroundrbを入れて
./script/generate worker DoSomething
すると
% ./script/generate worker DoSomething config/backgroundrb.yml vendor/plugins/backgroundrb/lib/backgroundrb.rb:16:in `init': You have a nil object when you didn't expect it! (NoMethodError) You might have expected an instance of Array. The error occurred while evaluating nil.[] from ./script/../config/../vendor/plugins/backgroundrb/lib/backgroundrb.rb:130 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' 略
って叱られた。@@configの中を見るとキーが文字列っぽかったので以下のようにしたら無事動作。
def self.init # @@config = YAML.load(File.open("#{BACKGROUNDRB_ROOT}/config/backgroundrb.yml")) @@config = YAML.load(ERB.new(IO.read("#{BACKGROUNDRB_ROOT}/config/backgroundrb.yml")).result) #@@server_ip = @@config[:backgroundrb][:ip] #@@server_port = @@config[:backgroundrb][:port] @@server_ip = @@config['backgroundrb']['ip'] @@server_port = @@config['backgroundrb']['port'] new end
なんかのバージョンの違いかなぁ・・・