2010/01/30

appengine-jrubyでRails2.3.5をWindowsで動かす

GAEでRailsを動かすRails 2.3.5 on App Engine (TinyDS)をWindowsでやってみた。

rails2_td_appengine.rbがcurlやらtailやら*nixのツール前提なのでRubyだけで書き直してみた。適当な直し。次のクローンはもっとうまくやってくれるでしょう。

#!/usr/bin/ruby # # Copyright:: Copyright 2009 Google Inc. # Original Author:: John Woodell (mailto:woodie@google.com) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require 'fileutils' require 'open-uri' def download(url, dest_file_name) open(url) do |src| open(dest_file_name, "wb") { |dest| dest.write(src.read) } end end FILE_BASE = 'http://appengine-jruby.googlecode.com/hg/demos/rails2/' MOD_FILES = %w{ app/controllers/rails/info_controller.rb config/boot_rb config/environment_td config/gae_boot_patch.rb config/initializers/gae_init_patch.rb config/database.yml config/initializers/session_store_rb config.ru } # Install Rails 2.3.5 FileUtils.touch 'config.ru' download("#{FILE_BASE}Gemfile_td", "Gemfile") system 'appcfg.rb.bat bundle --update .' # Remove dups and generate Rails app #FileUtils.rm 'public/robots.txt' system 'appcfg.rb.bat run -rthread bin/rails .' # Fetch configuration files FileUtils.mkdir_p 'app/controllers/rails' MOD_FILES.each do |path| download("#{FILE_BASE}#{path}", "#{path}") end # Merge configs into boot.rb open("boot", "wb") do |dest| open("config/boot.rb") do |src| dest.write(src.readlines[0,108]) end open("config/boot_rb") do |src| dest.write(src.read) end open("config/boot.rb") do |src| dest.write(src.readlines[-3,3]) end end #system 'head -n 108 config/boot.rb > boot' #system 'cat config/boot_rb >> boot' #system 'tail -n 3 config/boot.rb >> boot' FileUtils.rm 'config/boot_rb' FileUtils.mv 'boot', 'config/boot.rb' # Merge configs into environment.rb open("conf", "wb") do |dest| open("config/environment.rb") do |src| dest.write(src.readlines[0,30]) end open("config/environment_td") do |src| dest.write(src.read) end open("config/environment.rb") do |src| dest.write(src.readlines[-12, 12]) end end #system 'head -n 30 config/environment.rb > conf' #system 'cat config/environment_td >> conf' #system 'tail -n 12 config/environment.rb >> conf ' FileUtils.rm 'config/environment_td' FileUtils.mv 'conf', 'config/environment.rb' # Merge session_store initializer open("config/initializers/session_store.rb", "ab") do |dest| open("config/initializers/session_store_rb") do |src| dest.write(src.read) end end #system 'cat config/initializers/session_store_rb' + # ' >> config/initializers/session_store.rb' FileUtils.rm 'config/initializers/session_store_rb' # install the nulldb adapter system 'ruby script/plugin install http://svn.avdi.org/nulldb/trunk/' puts "##" puts "## Now type 'dev_appserver.rb .'" puts "##"

とりあえずプロジェクトが作れるところまでやった。続きの手順はまた今度やってみる。

0 件のコメント: