Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 58 lines (51 sloc) 1.432 kB
09d8e7a importing midilib
jimmsvn authored
1 #! /usr/bin/env ruby
2 #
3 # usage: install.rb [(--install-dir | -i) install_directory]
4 #
5 # This script installs midilib into the Ruby site-local library directory.
6 #
7 # Author:: Jim Menard (mailto:jimm@io.com)
da845cf Docs and copyright dates. Rake publish task publishes using "gem push".
Jim Menard authored
8 # Copyright:: Copyright (c) 2003-2010 by Jim Menard
09d8e7a importing midilib
jimmsvn authored
9 # License:: Distributed under the same license as Ruby.
10 #
11
12 require 'getoptlong'
13 require 'ftools'
14 require 'find'
15
16 SOURCE_DIR = 'lib'
17 LIB_DIR = 'midilib'
18 IO_DIR = File.join(LIB_DIR, 'io')
19
20 def instdir
21 g = GetoptLong.new(['--install-dir', '-i', GetoptLong::REQUIRED_ARGUMENT])
22 g.each { | name, arg |
23 if name == '--install-dir'
24 return arg
25 else
26 $stderr.puts "usage: $0 [--install-dir dir]"
27 end
28 }
29
30 begin
31 require 'rbconfig'
32 libdir = Config::CONFIG['sitedir'] + "/" +
33 Config::CONFIG['MAJOR'] + "." +
34 Config::CONFIG['MINOR']
35 rescue ScriptError
36 $LOAD_PATH.each do |l|
37 if l =~ /site_ruby/ && l =~ /\d$/ && l !~ /#{PLATFORM}/
38 libdir = l
39 break
40 end
41 end
42 STDERR.puts "Can't find required file `rbconfig.rb'."
43 STDERR.puts "The `midilib' files need to be installed manually in" +
44 " #{libdir}"
45 end
46 return libdir
47 end
48
49 INSTALL_DIR = instdir()
50 files = Dir.chdir('lib') { Dir['**/*.rb'] }
51
52 files.each { | f |
53 dir = File.dirname(f)
54 target_dir = File.join(INSTALL_DIR, dir)
55 File.makedirs(target_dir) unless File.exist?(target_dir)
56 File.install(File.join('lib', f), File.join(INSTALL_DIR, f), 0644, true)
57 }
Something went wrong with that request. Please try again.