dpklib

Up / ChangeLog / dpklib-1.0.6.tar.gz

dpklib is the miscellany library for Ruby including sample executable scripts.

Requirements

Least requirement is:

Programs

dpklib provides following command-line programs.

dpkruby-array [OPTIONS] EXPRESSION

Evalute EXPRESSION and prints as lines.

$ dpkruby-array -r gtk Gtk::Text.new.methods
dpkruby-dcp [OPTIONS] SRCDIR DESTDIR

Copies entire directory. If DESTDIR does not exists, it is created.

$ dpkruby-dcp dir-a/ dir-b/
dpkruby-discoveryd -m MAGIC_STRING -p PORT [PROGRAM [ARGS ...]]

Service discovery protocol server daemon. If PROGRAM is specified dpkruby-discoveryd executes PROGRAM and waits until PROGRAM exiting.

$ dpkruby-discoveryd -m my-server -p 5555 my-serverd
dpkruby-filter-replace [-r LIB] [-t TYPE] SCRIPT FILE ...

Evaluate SCRIPT for each FILE, and replace it with result.

$ dpkruby-filter-replace -r kconv 'Kconv.toeuc(src)' file1 file2
dpkruby-findres [OPTIONS] FILE ...
dpkruby-findres -l
dpkruby-findres -x -- PROGRAM [ARGS ...]
dpkruby-findres -F -- [FIND_ARGS ...]

Finds file from search path using dpklib/resource. (Dpklib::ResourceLoader)

$ dpkruby-findres -e PATH command
dpkruby-getopts ( SINGLE_OPT_SPEC | '' ) [LONG_OPT_SPEC ...] :: ARGS ...

Parse GNU getopt-like options and prints borune shell script for setting values. dpkruby-dcp is good example of this command.

#!/bin/sh
eval `dpkruby-getopts nvX cvs-exclude :: "$@"`
$OPT_USAGE && usage
if $OPT_n ...
dpkruby-install [OPTIONS] FILES ... DESTDIR

Installs files FILES into DESTDIR.

$ dpkruby-install -x bin/* `dpkruby-rbconfig bindir`
dpkruby-mvgsub [OPTIONS] [MATCHING_MODE] PATTERN REPLACED [FILES ...]

Renames file FILES name by pattern matching and replacing.

$ dpkruby-mvgsub -s .rb .cgi file1.rb file2.rb
dpkruby-passwd [-d] -f PASSWDFILE USERNAME

Manipulate MD5-encrypted password file like htpasswd(1).

dpkruby-rubyc-symbols

Parse ext-module's C source from stdin, and prints skelton Ruby code.

dpkruby-runit [OPTIONS] RBFILE ...

After loading each RBFILE, runs every test suites like 'require "rubyunit"' does. Requires RubyUnit.

$ dpkruby-runit -qL unittest/test-*.rb
dpkruby-rwpath [OPTIONS] PREFIX_OF_PATH FIND_FROM ...

Rewrites source-file part of common stacktrace. It strips PREFIX_OF_PATH from soruce file path, finds file in directories FIND_FROM, and substitute with found file's path.

Library

dpklib/parsearg.rb (Dpklib.parse_args)

dpklib/parsearg.rb provides GNU getopt-like option parser.

Dpklib.parse_args(argv, short_option_spec, *long_option_spec, ...)

Parses array of argument argv, and returns ParsedArguments object. If failed for invalid usage, returns nil.

short_option_spec and long_option_spec's usage is same as GNU getopt(3). Following extended usage is allowed:

Example:

argv = ["-ab", "b", "--long", "long1", "--long", "long2", "arg1"]
opts = Dpklib.parse_args(argv, "ab:c", "long::")
p opts[:a]  # => true
p opts[:b]  # => "b"
p opts[:c]  # => nil
p opts[:long]  # => ["long1", "long2"]
p opts.args  # => ["arg1"]

Copyright and License Notice

This program is free software distributed under BSD-style license term described in file COPYING.

Copyright 2003-, Shirai,Kaoru <shirai@korinkan.co.jp>