Permalink
Browse files

manual installation

  • Loading branch information...
1 parent 6af5626 commit 1609b33b6a0c0b4e475772dfa544818c027d2cfd Stefan Lang committed Dec 26, 2008
Showing with 159 additions and 3 deletions.
  1. +37 −0 INSTALL.txt
  2. +3 −0 README.txt
  3. +1 −1 Rakefile
  4. +116 −0 install.rb
  5. +2 −2 unicode_utils.gemspec
View
37 INSTALL.txt
@@ -0,0 +1,37 @@
+== Installing UnicodeUtils
+
+The easiest way to install UnicodeUtils is with RubyGems:
+
+ $ gem install unicode_utils
+
+=== Manual installation
+
+Two kinds of files must be installed:
+
+1. The library code. All files under <tt>lib/</tt> and
+ <tt>lib/unicode_utils/</tt> with suffix <tt>.rb</tt>.
+ The whole tree under <tt>lib/</tt> must be on the load path.
+
+2. The compiled Unicode data files under <tt>cdata/</tt>. UnicodeUtils
+ loads them from the <tt>UnicodeUtils::CDATA_DIR</tt> directory,
+ which is defined in <tt>read_cdata.rb</tt>.
+
+The best strategy is to copy the library files to Ruby's +sitelibdir+.
+You can get that by running:
+
+ $ ruby -r rbconfig -e "puts Config::CONFIG['sitelibdir']"
+
+Then copy all files under <tt>cdata/</tt> to
+<tt><sitelibdir>/unicode_utils</tt>. And last but not least, change
+the definition of +CDATA_DIR+ in
+<tt><sitelibdir>/unicode_utils/read_cdata.rb</tt> to
+<tt>File.absolute_path(File.dirname(\_\_FILE\_\_))</tt>.
+
+In fact, UnicodeUtils comes with an install.rb script that does
+all that:
+
+ $ ruby install.rb install
+
+or:
+
+ $ ruby install.rb install /some/other/dir
View
3 README.txt
@@ -6,6 +6,9 @@ Install with RubyGems:
Or get the source from Github: http://github.com/lang/unicode_utils
+For a non-RubyGems installation, read
+INSTALL.txt[link:files/INSTALL_txt.html].
+
UnicodeUtils works with Ruby 1.9.1-preview2 or later.
== Synopsis
View
2 Rakefile
@@ -22,7 +22,7 @@ desc "Run rdoc to generate html documentation."
task "doc" do
# Note: current Ruby 1.9.1 rdoc fails when a custom template
# is given. rdoc must be Ruby 1.8 version.
- sh "rdoc -o doc --inline-source --template=docsrc/jamis.rb --charset=UTF-8 --title=UnicodeUtils --main=README.txt lib README.txt"
+ sh "rdoc -o doc --inline-source --template=docsrc/jamis.rb --charset=UTF-8 --title=UnicodeUtils --main=README.txt lib README.txt INSTALL.txt"
end
desc "Publish doc/ on unicode-utils.rubyfore.org. " +
View
116 install.rb
@@ -0,0 +1,116 @@
+# -*- encoding: utf-8 -*-
+
+require "rbconfig"
+require "fileutils"
+
+sitelibdir = Config::CONFIG['sitelibdir']
+installdir = ARGV[1] || sitelibdir
+
+HELP = <<EOF
+Install unicode_utils.
+
+installdir defaults to Ruby's sitelibdir, which you can get
+with:
+
+ $ ruby -r rbconfig -e "puts Config::CONFIG['sitelibdir']"
+
+sitelibdir is #{sitelibdir.inspect}
+installdir is #{installdir.inspect}
+
+Possible commands are:
+
+ruby install.rb install [installdir]
+ Install unicode_utils in installdir. Fails when an
+ existing installation is found. Doesn't overwrite
+ existing files.
+
+ruby install.rb check [installdir]
+ Check if unicode_utils is installed in installdir.
+
+ruby install.rb uninstall [installdir]
+ Remove an existing unicode_utils installation in installdir.
+
+ruby install.rb help
+ Show this help.
+EOF
+
+def check(installdir)
+ puts "Checking for unicode_utils installation in #{installdir.inspect}"
+ found = false
+ if File.exist?(File.join(installdir, "unicode_utils.rb"))
+ puts "Found unicode_utils.rb"
+ found = true
+ end
+ if File.exist?(File.join(installdir, "unicode_utils"))
+ puts "Found unicode_utils/"
+ found = true
+ end
+ unless found
+ puts "No unicode_utils files/directories found."
+ end
+ found
+end
+
+def uninstall(installdir)
+ return unless check(installdir)
+ if File.exist?(File.join(installdir, "unicode_utils.rb"))
+ FileUtils::Verbose.rm File.join(installdir, "unicode_utils.rb")
+ end
+ if File.exist?(File.join(installdir, "unicode_utils"))
+ FileUtils::Verbose.rm_r File.join(installdir, "unicode_utils")
+ end
+end
+
+def install(installdir)
+ if check(installdir)
+ puts "You must run uninstall before install."
+ exit 1
+ end
+ installdir_lib = File.join(installdir, "unicode_utils")
+ FileUtils::Verbose.install "lib/unicode_utils.rb", installdir, mode: 0755
+ FileUtils::Verbose.mkdir installdir_lib
+ FileUtils::Verbose.install Dir["cdata/*"], installdir_lib, mode: 0755
+ found_cdata_dir = false
+ Dir.entries("lib/unicode_utils").each { |fn|
+ next unless fn =~ /.\.rb$/
+ if fn == "read_cdata.rb"
+ puts "writing read_cdata.rb"
+ File.open(File.join("lib/unicode_utils/read_cdata.rb"), "r:utf-8") do |input|
+ File.open(File.join(installdir_lib, "read_cdata.rb"), "w:utf-8") do |output|
+ input.each_line { |line|
+ if line =~ /^(\s+)CDATA_DIR =/
+ found_cdata_dir = true
+ puts "Setting CDATA_DIR to File.absolute_path(File.dirname(__FILE__))"
+ output.puts "#$1CDATA_DIR = File.absolute_path(File.dirname(__FILE__))"
+ else
+ output.puts line
+ end
+ }
+ end
+ end
+ FileUtils::Verbose.chmod 0755, File.join(installdir_lib, "read_cdata.rb")
+ else
+ FileUtils::Verbose.install File.join("lib/unicode_utils", fn), installdir_lib, mode: 0755
+ end
+ }
+ unless found_cdata_dir
+ puts "CDATA_DIR definition not found."
+ puts "Installation aborted."
+ exit 1
+ end
+ puts "Successfully installed unicode_utils in #{installdir.inspect}."
+end
+
+case ARGV[0]
+when "help"
+ print HELP
+when "install"
+ install(installdir)
+when "check"
+ check(installdir)
+when "uninstall"
+ uninstall(installdir)
+else
+ print HELP
+ exit 1
+end
View
4 unicode_utils.gemspec
@@ -5,7 +5,7 @@ require "#{File.dirname(__FILE__)}/lib/unicode_utils/version"
test_files = ["test/test_unicode_utils.rb"]
files =
Dir["lib/**/*.rb"] + Dir["cdata/*"] + test_files +
- ["README.txt", "LICENSE.txt"]
+ ["README.txt", "INSTALL.txt", "LICENSE.txt"]
files.reject! { |fn| fn.end_with?("~") }
Gem::Specification.new do |g|
@@ -20,7 +20,7 @@ Gem::Specification.new do |g|
g.author = "Stefan Lang"
g.email = "langstefan@gmx.at"
g.has_rdoc = true
- g.extra_rdoc_files = ["README.txt"]
+ g.extra_rdoc_files = ["README.txt", "INSTALL.txt"]
g.rdoc_options = ["--main=README.txt", "--charset=UTF-8"]
g.homepage = "http://github.com/lang/unicode_utils"
g.rubyforge_project = "unicode-utils"

0 comments on commit 1609b33

Please sign in to comment.