# $Id: Portfile 303 2011-07-31 16:14:46Z kimuraw $

PortSystem		1.0
PortGroup		ruby 1.0

name			rb-rurima-ja
version			20110729
platforms		darwin
categories		ruby
description		new Ruby reference manual (ja)
long_description	new Ruby reference manual (ja). you can use this manual \
				via the \"refe-(version)\" command or a web server with \"refe-server.rb\"
homepage		http://redmine.ruby-lang.org/wiki/rurema
maintainers		kimuraw@macports.org

master_sites	http://www.ruby-lang.org/ja/man/archive/ \
				http://doc.okkez.net/archives/[string range ${version} 0 5]/
license			docs:CC-BY-3.0, tools:Ruby
if {[info exists supported_archs]} {
	supported_archs noarch
}
distname		ruby-refm-1.9.2-dynamic-${version}

# for convenience
variant refe_as_18 conflicts refe_as_19 description \
		"install `refe' as shorter name of `refe_1_8_x'" {}
variant refe_as_19 conflicts refe_as_19 description \
		"install `refe' as shorter name of `refe_1_9_x'" {}

use_configure	no
build			{}
destroot {
	set ver18 1_8_7
	set ver19 1_9_2
	set rsrc_dir ${prefix}/share/${name}
	set refe_18 refe-${ver18}
	set refe_19 refe-${ver19}
	# install doc
	xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
	xinstall -m 644 ${worksrcpath}/readme.html \
		${destroot}${prefix}/share/doc/${name}/readme.html
	xinstall -m 644 ${filespath}/jp.nifty.i.kimuraw.refe-server.plist \
		${destroot}${prefix}/share/doc/${name}/refe-server.plist.sample
	# install command
	## refe commands
	xinstall -m 755 ${worksrcpath}/${refe_18} ${worksrcpath}/${refe_19} \
		${destroot}${prefix}/bin
	reinplace "s|^cd .*$|cd ${rsrc_dir}|" \
		${destroot}${prefix}/bin/${refe_18} ${destroot}${prefix}/bin/${refe_19}
	## server.rb as refe-server.rb
	xinstall -m 755 ${worksrcpath}/server.rb \
		${destroot}${prefix}/bin/refe-server.rb
	reinplace "s|^Dir.chdir .*$|Dir.chdir \"${rsrc_dir}\"|" \
		${destroot}${prefix}/bin/refe-server.rb
	# install db and resources
	xinstall -m 755 -d ${destroot}${rsrc_dir}
	system "tar -C ${worksrcpath} -cf - bitclust db-${ver18} db-${ver19} | tar -C ${destroot}${rsrc_dir} -xf -"

	# install `refe' for convenience
	if {[variant_isset refe_as_19]} {
		xinstall -m 755 ${destroot}${prefix}/bin/${refe_19} \
			${destroot}${prefix}/bin/refe
	}
	if {[variant_isset refe_as_18]} {
		xinstall -m 755 ${destroot}${prefix}/bin/${refe_18} \
			${destroot}${prefix}/bin/refe
	}
}

dist_subdir		ruby
checksums		md5 537f4f50272cea1ae20f5e08a025aa51 \
				sha1 5f727d4f0db95bf4b356aa6c3b4435892cd7e1b8 \
				rmd160 7192430a49a8dee2f82e4d878bd9fb1fb6a2dc86

