public
Description: gemified mirror of the tokyotyrant ruby interface
Homepage:
Clone URL: git://github.com/careo/tokyotyrant-ruby.git
Thu Apr 09 10:51:59 -0700 2009
careo (committer)
Mon Apr 20 20:30:40 -0700 2009
tokyotyrant-ruby / install.rb
100644 38 lines (33 sloc) 0.998 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'rbconfig'
 
sitelibdir = Config::CONFIG.fetch("sitelibdir")
bindir = Config::CONFIG.fetch("bindir")
 
def copy(src, dest, mode)
  p dest
  open(src, "rb") do |infile|
    open(dest, "wb") do |outfile|
      while buf = infile.read(8192)
        while buf.length > 0
          wlen = outfile.write(buf)
          buf = buf[wlen, buf.length]
        end
      end
      outfile.chmod(mode)
    end
  end
end
 
if ARGV.length > 0 && ARGV[0] == "uninstall"
  printf("uninstalling the library from %s ... ", sitelibdir)
  File.unlink("#{sitelibdir}/tokyotyrant.rb")
  printf("ok\n")
  printf("uninstalling the test command from %s ... ", bindir)
  File.unlink("#{bindir}/tcrtest.rb")
  printf("ok\n")
else
  printf("installing the library into %s ... ", sitelibdir)
  copy("tokyotyrant.rb", "#{sitelibdir}/tokyotyrant.rb", 0644)
  printf("ok\n")
  printf("installing the test command into %s ... ", bindir)
  copy("tcrtest.rb", "#{bindir}/tcrtest.rb", 0755)
  printf("ok\n")
end
 
printf("done\n")