technicalpickles’s jeweler at master – GitHub
$ sudo gem install jeweler
使い方は
Route 477 – gemspecの作り方がわからない?ならばjewelerだ
jeweler でらくらく rubygems 作成(github編) – まさにっき(コードで世界を変えたい人の記録)
を参考にする。
technicalpickles’s jeweler at master – GitHub
$ sudo gem install jeweler
使い方は
Route 477 – gemspecの作り方がわからない?ならばjewelerだ
jeweler でらくらく rubygems 作成(github編) – まさにっき(コードで世界を変えたい人の記録)
を参考にする。
まずはMacPortsでHyperEstraierのインストール。
$ sudo port install hyperestraier
~/local/varにクローラルートディレクトリを作成しました。クロール範囲を先日設定したsinatra-rubygemsのアドレスに設定。
$ estwaver init est_gemdoc $ nano est_gemdoc/_conf # seed documents seed: 1.0|http://gems.local allowrx: ^http://gems.local
クロールさせてみる。
$ estwaver crawl -revcont est_gemdoc
検索用CGIスクリプトを設置して設定を変更。
$ mkdir Sites/estraier $ cp /opt/local/libexec/estseek.cgi ~/Sites/estraier $ cp /opt/local/share/doc/hyperestraier/locale/ja/estseek.* ~/Sites/estraier $ nano ~/Sites/estraier/estseek.conf indexname: /Users/username/local/var/est_gemdoc/_index
Apache2の設定を変更。
$ sudo nano /etc/apache2/httpd.conf
AddHandler cgi-script .cgi
$ sudo nano /etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName estgd.local
DocumentRoot "/Users/username/Sites/estraier"
<directory "/Users/username/Sites/estraier">
Order allow,deny
Allow from all
Options ExecCGI
</directory>
</VirtualHost>
$ sudo apachectl gracefulで、estgd.localにアクセスすると、検索ページが表示された。
で、作業途中でRDocディレクトリをクロールさせてreplaceでURLに書き換えれば、クローラは必要ないんじゃないかと思った。それから~/Sites/estraierって名前だと抽象的すぎるよね…。
それからそれから、検索CGIをsinatraで作ってみたくなった。時間無いけど。
まずはRubyを1.9から1.8に変更したので、再度SinatraやPassengerをインストールしたりいろいろ。
$ sudo gem install sinatra $ sudo gem install passenger $ sudo passenger-install-apache2-module $ sudo nano /etc/apache2/httpd.conf LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.5 PassengerRuby /opt/local/bin/ruby
あいかわらずPassenger Preference Pane · Fingertipsが動かない。MacPortsのRubyだから?
仕方ないので手動で設定。
まずsinatra-rubygemsを~/Sitesにclone。
$ cd ~/Sites
$ git clone git://github.com/jnewland/sinatra-rubygems.git
$ sudo nano /etc/hosts
127.0.0.1 gems.local
$ sudo nano /etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName gems.local
#ServerAlias custom.gem.server.fqdn
DocumentRoot "/Users/username/Sites/sinatra-rubygems/public"
RackEnv production
<directory "/Users/username/Sites/sinatra-rubygems/public">
Order allow,deny
Allow from all
</directory>
</VirtualHost>
$ sudo apachectl gracefulgems.localにアクセスするとドキュメントindexが表示された。
先日作成したSinatraのテンプレートにwycats’s bundler at master – GitHubを導入してみた。
まず、SinatraアプリをSinatra::Baseを継承したクラス化。
アプリルートにGemfileファイルを以下の内容で作成。
gem "sinatra", "0.9.4", :require_as => "sinatra/base" gem "rack", "1.0.1" gem "rack-flash", "0.1.1", :require_as => "rack/flash" gem "haml", "2.2.13" gem "chriseppstein-compass", "0.8.17", :require_as => "compass" gem "dm-core", "0.10.1"
アプリルートのgemsにバンドルを保存して、利用するgemを記述。
app.rbの先頭のsinatraなどのrequireを削除して以下を追加。
require File.expand_path(File.join(File.dirname(__FILE__), 'vendor', 'gems', 'environment')) Bundler.require_env
アプリルートで
$ gem bundle
を実行して、利用するgemをダウンロードして環境を作成します。
デフォルトではvender/gemsにダウンロードされて、実行ファイルはbinに配置される。変更可能。
で、
$ ruby app.rb
すると、これまでと変わらずsinatraアプリが実行される。
テストでのみ利用するgemはGemfileに
only :test do gem 'shoulda', "2.10.2" gem 'rack-test', "0.5.2", :require_as => "rack/test" end
アプリをクラス化したのでテストも書き換え。
test/test_helper.rbを作って
require File.join(File.dirname(__FILE__), '..', 'app.rb') require 'test/unit' require File.expand_path(File.join(APP_ROOT, 'vendor', 'gems', 'environment')) Bundler.require_env :test module TestHelper include Rack::Test::Methods def app SinatraApp end end Test::Unit::TestCase.send(:include, TestHelper)
test/app_test.rbを下記に変更。
require File.dirname(__FILE__) + '/test_helper' class AppTest < Test::Unit::TestCase context "Access pages" do should "show index" do get '/' assert_match 'Say hello!', last_response.body end should "show hello" do post '/hello' follow_redirect! assert_match 'Hello world!', last_response.body end end end
features/support/env.rb
# -*- encoding: UTF-8 -*- require File.join(File.dirname(__FILE__), '../../app.rb') require File.expand_path(File.join(APP_ROOT, 'vendor', 'gems', 'environment')) Bundler.require_env :test require 'test/unit/assertions' Encoding.default_external = 'UTF-8' Webrat.configure do |config| config.mode = :rack config.application_framework = :sinatra config.application_port = 4567 end World(Test::Unit::Assertions) do def app SinatraApp end include Rack::Test::Methods include Webrat::Methods include Webrat::Matchers end Before do DataMapper.auto_migrate! end