Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts about Ruby.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/ruby.e>
#           or at <http://angg.twu.net/e/ruby.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######





# «.ruby-full»			(to "ruby-full")
# «.irb»			(to "irb")
# «.irbrc»			(to "irbrc")
# «.rubyri»			(to "rubyri")
# «.instance_variables»		(to "instance_variables")
# «.webrick»			(to "webrick")
# «.hello2.cgi»			(to "hello2.cgi")
# «.hello3.cgi»			(to "hello3.cgi")
# «.demo-app.rb»		(to "demo-app.rb")
# «.methods-as-closures»	(to "methods-as-closures")
# «.ruby-from-debian-sources-etch»  (to "ruby-from-debian-sources-etch")
# «.ruby-from-debian-sources»	(to "ruby-from-debian-sources")
# «.ruby1.8.7-deb-src»		(to "ruby1.8.7-deb-src")
# «.ruby-from-upstream»		(to "ruby-from-upstream")
# «.gem»			(to "gem")
# «.gem_server»			(to "gem_server")
# «.gems-from-debian-source»	(to "gems-from-debian-source")
# «.gems-debian-repository»	(to "gems-debian-repository")
# «.ruby-postgres»		(to "ruby-postgres")
# «.ruby-postgres-test1»	(to "ruby-postgres-test1")
# «.ruby-postgres-gdb»		(to "ruby-postgres-gdb")
# «.ruby-postgres-gems»		(to "ruby-postgres-gems")
# «.postgres-from-ruby»		(to "postgres-from-ruby")
# «.gems-are-tar-files»		(to "gems-are-tar-files")
# «.postgres-pr»		(to "postgres-pr")
# «.postgres-pr-test»		(to "postgres-pr-test")
# «.postgres-pr-mident-error»	(to "postgres-pr-mident-error")
# «.mident-error-gdb-psql»	(to "mident-error-gdb-psql")
# «.LOAD_PATH»			(to "LOAD_PATH")
# «.mongrel»			(to "mongrel")
# «.edrxinit:postgres-pr»	(to "edrxinit:postgres-pr")
# «.pragmatic»			(to "pragmatic")
# «.ruby-in-a-nutshell»		(to "ruby-in-a-nutshell")
# «.el4r»			(to "el4r")
# «.ruby-mode.el»		(to "ruby-mode.el")
# «.test.unit»			(to "test.unit")
# «.ruby-manual»		(to "ruby-manual")
# «.rdoc»			(to "rdoc")
# «.anonymous-classes»		(to "anonymous-classes")
# «.singleton_class»		(to "singleton_class")
# «.klass-and-super»		(to "klass-and-super")
# «.evil.rb»			(to "evil.rb")
# «.ruby-mysql»			(to "ruby-mysql")
# «.multiline-comments»		(to "multiline-comments")
# «.require»			(to "require")
# «.topological-sort»		(to "topological-sort")
# «.learnxinyminutes»		(to "learnxinyminutes")
# «.functions»			(to "functions")
# «.irb-options»		(to "irb-options")
# «.a-compiler-from-scratch»	(to "a-compiler-from-scratch")
# «.rsyntaxtree»		(to "rsyntaxtree")
# «.rbenv»			(to "rbenv")







# (find-zsh "installeddebs | sort | grep ruby")
# (find-zsh "availabledebs | sort | grep ruby")
# (find-zsh "installeddebs | sort | grep irb")
# (find-zsh "availabledebs | sort | grep irb")

# (find-status   "libruby2.3")
# (find-vldifile "libruby2.3:amd64.list")
# (find-udfile   "libruby2.3/")
# (find-status   "ruby2.3")
# (find-vldifile "ruby2.3.list")
# (find-udfile   "ruby2.3/")
# (find-status   "ruby2.3-doc")
# (find-vldifile "ruby2.3-doc.list")
# (find-udfile   "ruby2.3-doc/")
# (find-status   "ruby")
# (find-vldifile "ruby.list")
# (find-udfile   "ruby/")
# (find-status   "ruby-did-you-mean")
# (find-vldifile "ruby-did-you-mean.list")
# (find-udfile   "ruby-did-you-mean/")
# (find-status   "ruby-power-assert")
# (find-vldifile "ruby-power-assert.list")
# (find-udfile   "ruby-power-assert/")

# (find-udfile "ruby/changelog.gz")
# (find-udfile "ruby/copyright")
# (find-udfile "ruby/README.Debian")
# (find-udfile "ruby/NEWS.Debian.gz")
# (find-fline "/usr/share/man/man1")
# (find-fline "/usr/bin/ri")
# (find-fline "/usr/bin/rdoc")
# (find-fline "/usr/bin/gem")
# (find-fline "/usr/bin/irb")
# (find-fline "/usr/bin/erb")
# (find-fline "/usr/bin/ruby")
# (find-man "1 ri")
# (find-man "1 ruby")
# (find-man "1 irb")
# (find-man "1 erb")
# (find-man "1 rdoc")
# (find-man "1 gem")





#####
#
# ruby-full
# 2009oct02
#
#####

# «ruby-full»  (to ".ruby-full")
# (find-status   "ruby-full")
# (find-vldifile "ruby-full.list")
# (find-udfile   "ruby-full/")





irb

ruby1.9-dev
ruby1.9-elisp
ruby1.9-examples
ruby1.9
rubybook




# apt-get install irb ruby ruby-elisp ruby1.8-examples ruby-manual ri
apt-get install irb ruby ruby-elisp ruby1.8-examples ri
apt-get install rubybook

# (find-udfile "irb/")
# (find-udfile "ruby-elisp/")
# (find-udfile "ruby1.8-examples/")
# (find-udfile "ruby1.8-examples/examples/")
# (find-udfile "ruby-manual/")
# (find-udfile "ruby/")
# (find-udfile "rubybook/")
# (find-udfile "rubybook/html/")
# (find-status "irb")
# (find-status "ruby")
# (find-status "ruby-elisp")
# (find-status "ruby-examples")
# (find-status "ruby-manual")
# (find-status "rubybook")
# (find-vldifile "irb.list")
# (find-vldifile "ruby-elisp.list")
# (find-vldifile "ruby1.8-examples.list")
# (find-vldifile "ruby-manual.list")
# (find-vldifile "ruby.list")
# (find-vldifile "rubybook.list")

# (find-man "1 irb")
# (find-man "1 ruby")

(code-c-d "rubybook"   "/usr/share/doc/rubybook/html/")
(code-c-d "rubymanual" "/usr/share/doc/ruby-manual/html/")
(code-c-d "rubyfaq"    "/usr/share/doc/ruby-manual/faq/")

;; (find-rubymanualfile "")
;; (find-rubymanualw3m "syntax.html" "\nEmbedded Documentation\n")
;; (find-rubymanualw3m "index.html")
;; (find-rubybookfile "")
;; (find-rubyfaqfile "")



#####
#
# irb: interactive ruby shell
# 2019jun25
#
#####

# «irb» (to ".irb")
# (find-man "1 irb")
# (find-man "1 irb" "--simple-prompt")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
irb
quit
irb --simple-prompt
quit



#####
#
# The ~/.irbrc file
# 2019jun25
#
#####

# «irbrc» (to ".irbrc")
# (find-angg ".irbrc")




#####
#
# ri
# 2012apr21 / 2019jun25
#
#####

# «rubyri»  (to ".rubyri")
# (find-angg ".emacs" "ruby")
# http://rubylearning.com/satishtalim/ruby_ri_tool.html

# (find-status   "ruby2.3-doc")
# (find-vldifile "ruby2.3-doc.list")
# (find-udfile   "ruby2.3-doc/")
# (find-fline "/usr/share/ri/2.3.0/system/")
# (find-fline "/usr/share/ri/2.3.0/system/Hash/")
# (find-sh "ri inherited")

# (find-rubyri "Array")
# (find-rubyri "Array.sort")
# (find-rubyri "Hash#each")
# (find-rubyri "Math::sqrt")


# (find-man "ri")
# (find-sh "ri Fil")
# (find-sh "ri File")
# (find-sh "ri File.new")
# (find-sh "ri File.new" 1 '(Man-fontify-manpage))
# (find-rubyri "File.new")
# (find-sh "ri zip")
# (find-sh "ri 'Array.[]'")
# (find-sh "ri compact")





#####
#
# spuk's tutorial (in Portuguese)
# 2002jul27
#
#####

rm -Rv $usr_src/tutorial-ruby_0.3.2/
cd $usr_src/
tar -xvzf $S/http/www.inf.ufsc.br/~nardin/ruby/tutorial-ruby_0.3.2.tar.gz
cd $usr_src/tutorial-ruby_0.3.2/
lynx -dump tutorial-ruby_0.3.2.html > tutorial.txt

# (code-c-d "tutruby" "$usr_src/tutorial-ruby_0.3.2/")
# (find-tutrubyfile "")
# (find-tutrubyfile "tutorial.txt")

lynx http://www.inf.ufsc.br/~nardin/edrx/

* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
class Teste       # Define classe Teste
  def set(v)      # Define metodo 'set' com argumento v
    @v = v        # Inicializa o atributo @v
  end
  def get
    @v
  end
end
a = Teste.new     # a se refere a um novo objeto Teste
b = a             # b se refere ao mesmo objeto que a
a.set("oi")
a.get             # >> oi
b.get             # >> oi


* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
class Teste       # Define classe Teste
  def set(v)      # Define metodo 'set' com argumento v
    @v = v        # Inicializa o atributo @v
  end
  def get
    @v
  end
end
a = Teste.new     # a se refere a um novo objeto Teste
b = a             # b se refere ao mesmo objeto que a
a.set("oi")
p(a.get)          # >> oi
p(b.get)          # >> oi




#####
#
# class variables
# 2007may25
#
#####

# «instance_variables»  (to ".instance_variables")
# (find-books "__comp/__comp.el" "ruby")
# (find-rubynutshellpage 31)
# (find-rubynutshelltext " @foo")
# (find-rubynutshelltext " @@foo")

* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
class Foo
  def set(v); @v = v; end
  def get;    @v;     end
end
a = Foo.new; a.set "bletch"
b = Foo.new; b.set "plic"
a.get   #-> "bletch"
b.get   #-> "plic"

class Bar
  def set(v); @@v = v; end
  def get;    @@v;     end
end
a = Bar.new; a.set "bletch"
b = Bar.new; b.set "plic"
a.get   #-> "plic"
b.get   #-> "plic"




#####
#
# ruby1.8 debian source
#
#####

http://ftp.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.2-3.diff.gz
http://ftp.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.2-3.dsc
http://ftp.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.2.orig.tar.gz





# http://www.dagbrown.com/software/gurgitate-mail/gurgitate-mail-1.4.1.tar.gz
rm -Rv ~/


apti ri ri-cs-el ruby1.8-dev ruby1.8-elisp ruby1.8-examples rubybook

# (find-status   "irb1.8")
# (find-vldifile "irb1.8.list")
# (find-udfile   "irb1.8/")
# (find-status   "libiconv-ruby1.8")
# (find-vldifile "libiconv-ruby1.8.list")
# (find-udfile   "libiconv-ruby1.8/")
# (find-status   "libreadline-ruby1.8")
# (find-vldifile "libreadline-ruby1.8.list")
# (find-udfile   "libreadline-ruby1.8/")
# (find-status   "libruby1.6")
# (find-vldifile "libruby1.6.list")
# (find-udfile   "libruby1.6/")
# (find-status   "libruby1.8")
# (find-vldifile "libruby1.8.list")
# (find-udfile   "libruby1.8/")
# (find-status   "libyaml-ruby1.8")
# (find-vldifile "libyaml-ruby1.8.list")
# (find-udfile   "libyaml-ruby1.8/")
# (find-status   "rdoc1.8")
# (find-vldifile "rdoc1.8.list")
# (find-udfile   "rdoc1.8/")
# (find-status   "ri")
# (find-vldifile "ri.list")
# (find-udfile   "ri/")
# (find-status   "ri-cs-el")
# (find-vldifile "ri-cs-el.list")
# (find-udfile   "ri-cs-el/")
# (find-status   "ri1.6")
# (find-vldifile "ri1.6.list")
# (find-udfile   "ri1.6/")
# (find-status   "ri1.8")
# (find-vldifile "ri1.8.list")
# (find-udfile   "ri1.8/")
# (find-status   "ruby1.6")
# (find-vldifile "ruby1.6.list")
# (find-udfile   "ruby1.6/")
# (find-status   "ruby1.8")
# (find-vldifile "ruby1.8.list")
# (find-udfile   "ruby1.8/")
# (find-status   "ruby1.8-dev")
# (find-vldifile "ruby1.8-dev.list")
# (find-udfile   "ruby1.8-dev/")
# (find-status   "ruby1.8-examples")
# (find-vldifile "ruby1.8-examples.list")
# (find-udfile   "ruby1.8-examples/")
# (find-status   "rubybook")
# (find-vldifile "rubybook.list")
# (find-udfile   "rubybook/")


# (code-c-d "rubybook" "/usr/share/doc/rubybook/html/")
# (find-rubybookfile "")
# (find-rubybookw3m "index.html")
# (find-rubybookw3m "intro.html")
# (find-rubybookw3m "intro.html" "Example variable and class names")
# (find-rubybookw3m "intro.html" "hash literal")
# (find-rubybookw3m "intro.html" "yield")
# (find-rubybookw3m "builtins.html")

# (find-rubybookw3m "tut_containers.html" "\nHashes\n")
# (find-rubybookw3m "tut_containers.html" "\nImplementing Iterators\n")
# (find-rubybookw3m "tut_containers.html" "|f|")
# (find-rubybookw3m "tut_containers.html" "do |aFile|")
# (find-rubybookw3m "tut_stdtypes.html" "1.upto(5)")
# (find-rubybookw3m "tut_stdtypes.html" "showRE")
# (find-rubybookw3m "tut_methods.html" "*['a', 'b']")
# (find-rubybookw3m "tut_methods.html" "Collecting Hash Arguments")
# (find-rubybookw3m "tut_expressions.html" "(a.*(b)).+(c)")
# (find-rubybookw3m "tut_expressions.html" "def `(cmd)")
# (find-rubybookw3m "tut_expressions.html" "def duration=(newDuration)")
# (find-rubybookw3m "tut_expressions.html" "a, b = b, a")
# (find-rubybookw3m "tut_expressions.html" "Nested Assignments")
# (find-rubybookw3m "rubyworld.html" "RUBYOPT")
# (find-rubybookw3m "language.html")
# (find-rubybookw3m "language.html" "a.each { |i|  puts i  }")
# (find-rubybookw3m "language.html" "singleton methods")

# (find-sh "ri1.8 Proc")
# (find-sh "ri1.8 Kernel")
# (find-sh "ri1.8 lambda")
# (find-fline "/usr/share/ri/1.8/system/Proc/cdesc-Proc.yaml")

# (find-man "1 ri")
# (find-sh "ri Array")
# (find-sh "ri Array.+")
# (find-udfile "ruby1.8/README.Debian")


#!/usr/bin/ruby
# Server: ruby p2p.rb password server public-uri private-uri merge-servers
# Sample: ruby p2p.rb foobar server druby://123.123.123.123:1337
#         druby://:1337 druby://foo.bar:1337
# Client: ruby p2p.rb password client server-uri download-pattern [list-only]
# Sample: ruby p2p.rb foobar client druby://localhost:1337 *.rb
################################################################################
require'drb';F=File;P,M,U,V,*O=ARGV;def c(u)DRbObject.new((),u)end;def x(u);[P,u
].hash;end;def s(p);F.basename p[/[^|]+/];end;M["s"]?(DRb.start_service V,Class.
new{def p(z=O)O.push(*z).uniq;end;new.methods.map{|m|m[/_[_t]/]||private(m)};def
y;(p(U)+p).map{|u|u!=U&&c(u).f(x(u),p(U))};self;end;def f(c,a=[],t=2)x(U)==c&&t<
1?Dir[s(a)]:t<2?[*open(s(a),"rb")]:p(a)end}.new.y;sleep):c(U).f(x(U)).map{|n|c(n
).f(x(n),V,0).map{|f|s f}.sort.map{|f|O[0]?p(f):open(f,"wb")<<c(n).f(x(n),f,1)}}


require'drb';
F=File;P,M,U,V,*O=ARGV;
def c(u)DRbObject.new((),u)end;
def x(u);[P,u].hash;end;
def s(p);F.basename p[/[^|]+/];end;
M["s"]?(DRb.start_service V,
    Class.new{def p(z=O)O.push(*z).uniq;end;
              new.methods.map{|m|m[/_[_t]/]||private(m)};
              def y;(p(U)+p).map{|u|u!=U&&c(u).f(x(u),p(U))};self;end;
              def f(c,a=[],t=2)x(U)==c&&t<1?
                      Dir[s(a)]:
                      t<2?
                        [*open(s(a),"rb")]:
                        p(a)end
             }.new.y;
    sleep):c(U).f(x(U)).map{|n|c(n
).f(x(n),V,0).map{|f|s f}.sort.map{|f|O[0]?p(f):open(f,"wb")<<c(n).f(x(n),f,1)}}






#####
#
# webrick demos
# 2006jun23
#
#####

# «webrick»  (to ".webrick")
# http://www.webrick.org/
# (find-rubyexfile "")
# (find-rubyexfile "webrick/hello.rb")
# (find-rubyexfile "webrick/hello.cgi")
# (find-rubyexfile "webrick/")
# (find-rubyexfile "webrick/demo-app.rb" "file size too large")
# (find-fline "/var/www/webrick/")
# (find-fline "/var/www/webrick/hello.cgi")
# (find-fline "/var/www/webrick/hello2.cgi")
#*
sudo rm -Rv    /var/www/webrick/
sudo mkdir  -p /var/www/webrick/
sudo chmod 777 /var/www/webrick/
cp -iv /usr/share/doc/ruby1.8-examples/examples/webrick/* \
               /var/www/webrick/
chmod -v 755   /var/www/webrick/*.cgi
cd             /var/www/webrick/

# «hello2.cgi»  (to ".hello2.cgi")
cat > hello2.cgi <<'---'
#!/usr/bin/ruby1.8
require "webrick/cgi"
class HelloCGI < WEBrick::CGI
  def do_GET(req, res)
    res["content-type"] = "text/plain"
    # res.body = "Hello, world.\n"
    res.body = req.inspect
  end
  def do_POST(req, res)
    res["content-type"] = "text/plain"
    # res.body = "Hello, world.\n"
    res.body = req.inspect
  end
end
HelloCGI.new.start
---
chmod 755 hello2.cgi

#*
<!-- (ee-once (eehtml-bounded))
  -- (eehtml-bounded)
  -- http://localhost/webrick/
  -- file:///tmp/ee.html
  -->
<form name="compose" action="http://localhost/webrick/hello2.cgi" method="post" enctype="multipart/form-data">
  <input type="file" name="afile" size="48" /><br />
  <input name="atext" value="foo" size=5 maxlength=10/><br />
  <input type="submit" name="attach" value="Run foo.cgi" />
</form>

#*
# «hello3.cgi»  (to ".hello3.cgi")

cd /var/www/webrick/
cat > /var/www/webrick/hello3.cgi <<'--%%--'
#!/usr/bin/ruby1.8
require "webrick/cgi"
class HelloCGI < WEBrick::CGI
  def do_POST(req, res)
    res["content-type"] = "text/plain"
    res["content-type"] = "text/html"
    # res.body = "Hello, world.\n"
    # res.body = req.inspect
    # (find-rubylibfile "webrick/")
    # (find-rubyexfile "webrick/demo-app.rb")
    #{HTTPUtils::quote(req.query)}
      res.body = <<-_end_of_html_
      #{req.query["atext"]}
      #{req.query["afile"]}
      #{req.query["afile"].filename}
      <br />
      #{req.query.inspect}
      #{req.query['afile'].methods.sort.inspect}
      <form name="compose" action="hello3.cgi"
            method="post" enctype="multipart/form-data">
        <input name="afile" type="file" size="48" /><br />
        <input name="atext" value="#{req.query["atext"]}"
               size=5 maxlength=10/><br />
        <input type="submit" name="attach" value="Run foo.cgi" />
      </form>
_end_of_html_
  end
  def do_GET(req, res)
    do_POST(req, res)
  end
end
HelloCGI.new.start
--%%--
chmod 755 /var/www/webrick/hello3.cgi

# http://localhost/webrick/hello3.cgi

#*

<edrx> may I ask a really beginner-ish question? :-) how do I check if
       a variable fname matches the regexp
       ^[-_A-Za-z0-9]+\.{html,jpg,png,txt}$ ? how do I save the
       contents of req.query["afile"] to the file named fname if it
       matches?
<slyphon> varname =~ /foobar/
*** DarkPhantom JOIN
<edrx> hmm, if varname =~ /foobar/ then blah end, I guess
<teferi> or fname.match(regex)
<teferi> or regex.match(var)
<edrx> ok
<slyphon> =~ // is faster
<slyphon> there's a hack in the interpreter
<teferi> by how many nanoseconds?
<slyphon> enough to make a difference

@peeraddr=[nil, 0, "127.0.0.1", "127.0.0.1"]






#####
#
# webrick and file uploads
# 2006jun23
#
#####

# (find-fline "$ASROOT/var/www/")
# (find-fline "$ASROOT/var/www/rubytest.cgi")
# (find-sh0 "sudo chmod 755 /var/www/rubytest.cgi")

# (find-fline "$ASROOT/var/www/")
# (find-fline "$ASROOT/var/www/rubytest.cgi")

#!/usr/bin/ruby1.8
#!/usr/bin/ruby
# (find-angg ".emacs" "ruby")
# (find-rubyexfile "")
# (find-rubyexfile "webrick/hello.rb")
# (find-rubyexfile "webrick/hello.cgi")

require "webrick/cgi"

class HelloCGI < WEBrick::CGI
  def do_GET(req, res)
    res["content-type"] = "text/plain"
    res.body = "Helllo, world.\n"
  end
end

HelloCGI.new.start








#####
#
# webrick and file uploads
# 2006jun23
#
#####

# (find-es "tcl" "cgi.tcl")
# http://localhost/cgi-tcl/upload.cgi

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SquirrelMail</title>
</head>
<body>
<form name="compose" action="compose.php" method="post" enctype="multipart/form-data">
  <input type="submit" name="sigappend" value="Signature" />
  <input type="submit" name="html_addr_search" value="Addresses" />
  <input type="submit" name ="draft" value="Save Draft" />
  <input type="submit" name="send" value="Send" />
  <textarea name="body" id="body" rows="20" cols="76" wrap="virtual">
  </textarea>
  <input type="submit" name="send" value="Send" />
  <input type="hidden" name="MAX_FILE_SIZE" value="2097152" />
  <input name="attachfile" size="48" type="file" />
  <input type="submit" name="attach" value="Add" />
  <input type="hidden" name="username" value="edrx" />
</form>
</body>
</html>





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SquirrelMail</title>
</head>
<body>

#*
<!-- (ee-once (eehtml-bounded))
  -- (eehtml-bounded)
  -- file:///tmp/ee.html
  -->
<form name="compose" action="http://localhost/webrick/hello2.cgi" method="post" enctype="multipart/form-data">
  <input type="file" name="file1" size="48" />
  <br />
  <input type="submit" name="attach" value="Run foo.cgi" />
</form>
#*
</body>
</html>





#####
#
# trying to understand webrick/demo-app.rb
# 2006jul03
#
#####

# «demo-app.rb»  (to ".demo-app.rb")
# (find-rubyexfile "webrick/demo-app.rb" "file size too large")

# "<<" treats its left argument as an Lvalue...

* (eepitch-shell)
irb
foo = "O_"
p foo
foo << "o"
p foo
foo = "ab"; foo << "cd"
help "String#<<"
help String#<<
quit

# (find-man "ri")
# (find-sh "PAGER=cat ri1.8 'String#<<'")

# (find-rubysrcfile "")
# (find-rubysrcsh "grep 'Concatenates the given object to' $(find *)")
# (find-rubysrcfile "string.c" "Concatenates the given object to")
# (find-rubymanualw3m "syntax.html#method")

<ayrnieu>
class Array
  def rand
    self[super length]
  end
end
, to give my favorite example.  [1,2,3].rand doesn't 'receive' [1,2,3] as any kind of L or R value.

# (find-sh "PAGER=cat ri1.8 method")



#####
#
# methods are closures with a "self" variable
# 2006jul04
#
#####

# «methods-as-closures»  (to ".methods-as-closures")
# http://xahlee.org/Periodic_dosage_dir/t2/oop.html
# http://www.forcix.cx/software/prometheus.html




#####
#
# ruby-1.8.5 from the debian sources (on etch)
# 2007apr25
#
#####

# «ruby-from-debian-sources-etch»  (to ".ruby-from-debian-sources-etch")
# http://ftp.debian.org/debian/pool/main/r/ruby1.8/
# http://ftp.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.5-4.dsc
# http://ftp.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.5-4.diff.gz
# http://ftp.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.5.orig.tar.gz
#*
apti dbs bison libgdbm-dev tk8.4-dev libssl-dev
apti fakeroot autoconf

#*
rm -Rv ~/usrc/ruby1.8/
mkdir  ~/usrc/ruby1.8/
cd $S/http/ftp.debian.org/debian/pool/main/r/ruby1.8/
cp -v ruby1.8_1.8.5* ~/usrc/ruby1.8/
cd     ~/usrc/ruby1.8/
dpkg-source -sn -x ruby1.8_1.8.5-4.dsc

# (find-fline "~/usrc/ruby1.8/")
# (find-fline "~/usrc/ruby1.8/ruby1.8-1.8.5/")
cd ~/usrc/ruby1.8/ruby1.8-1.8.5/
# find * -name '*.[ch]' | sort > .files.ch
# etags $(cat .files.ch)

cd     ~/usrc/ruby1.8/ruby1.8-1.8.5/
dpkg-buildpackage -us -uc -b -rfakeroot     |& tee odb

#*
# (code-c-d "rubysrc" "~/usrc/ruby1.8/ruby1.8-1.8.5/")
# (find-rubysrcfile "")
# (find-rubysrcfile "odb")
# (find-rubysrcfile "odb" "source_unpack")




#####
#
# ruby-1.8.2 from the debian sources
# 2006jul03
#
#####

# «ruby-from-debian-sources»  (to ".ruby-from-debian-sources")
# mainly because ri1.8 is not in the first debian CDs...
# http://packages.debian.org/stable/source/ruby1.8
# http://security.debian.org/debian-security/pool/updates/main/r/ruby1.8/ruby1.8_1.8.2-7sarge2.diff.gz
# http://security.debian.org/debian-security/pool/updates/main/r/ruby1.8/ruby1.8_1.8.2-7sarge2.dsc
# http://security.debian.org/debian-security/pool/updates/main/r/ruby1.8/ruby1.8_1.8.2.orig.tar.gz
# (code-c-d "ruby" "~/usrc/ruby/ruby1.8-1.8.2/")
# (find-rubyfile "")
# (find-rubyfile "odb")
#*
apti dbs bison libgdbm-dev tk8.4-dev libssl-dev
apti fakeroot

#*
rm -Rv ~/usrc/ruby/
mkdir  ~/usrc/ruby/
cd $S/http/security.debian.org/debian-security/pool/updates/main/r/ruby1.8/
cp -v ruby1.8_1.8.2* ~/usrc/ruby/
cd     ~/usrc/ruby/
dpkg-source -sn -x ruby1.8_1.8.2-7sarge2.dsc

cd ~/usrc/ruby/ruby1.8-1.8.2/build-tree/ruby-1.8.2/
find * -name '*.[ch]' | sort > .files.ch
etags $(cat .files.ch)

cd ~/usrc/ruby/ruby1.8-1.8.2/
dpkg-buildpackage -us -uc -b -rfakeroot		|& tee odb

#*
cd     ~/usrc/ruby/
sudo dpkg -i *.deb

#*



#####
#
# ruby1.8.7 (from the debian sources)
# 2008oct31
#
#####

# «ruby1.8.7-deb-src»  (to ".ruby1.8.7-deb-src")
# http://ftp.debian.org/debian/pool/main/r/ruby1.8/
# http://ftp.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.7.72-1.dsc
# http://ftp.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.7.72-1.diff.gz
# http://ftp.debian.org/debian/pool/main/r/ruby1.8/ruby1.8_1.8.7.72.orig.tar.gz
#*
sudo apt-get build-dep ruby1.8

#*
rm -Rv ~/usrc/ruby1.8/
mkdir  ~/usrc/ruby1.8/
cd $S/http/ftp.debian.org/debian/pool/main/r/ruby1.8/
cp -v ruby1.8_1.8.7.72* ~/usrc/ruby1.8/
cd     ~/usrc/ruby1.8/
dpkg-source -sn -x ruby1.8_1.8.7.72-1.dsc

# cd ~/usrc/ruby/ruby1.8-1.8.2/build-tree/ruby-1.8.2/
# find * -name '*.[ch]' | sort > .files.ch
# etags $(cat .files.ch)

cd     ~/usrc/ruby1.8/ruby1.8-1.8.7.72/
dpkg-buildpackage -us -uc -b -rfakeroot     |& tee odb

#*
# (find-fline "~/usrc/ruby1.8/")
* (eepitch-shell)
cd ~/usrc/ruby1.8/
sudo dpkg -i *.deb

#*
# (code-c-d "ruby1.8" "~/usrc/ruby1.8/ruby1.8-1.8.7.72/")
# (find-ruby1.8file "")





#####
#
# ruby-1.8.6 from upstream (mainly for rdebug)
# 2007apr27
#
#####

# «ruby-from-upstream»  (to ".ruby-from-upstream")
# ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2
#*
rm -Rv ~/usrc/ruby-1.8.6/
tar -C ~/usrc/ -xvjf \
  $S/ftp/ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2
cd     ~/usrc/ruby-1.8.6/

find *                | sort > .files
find * -name '*.[ch]' | sort > .files.ch
etags $(cat .files.ch)

./configure |& tee oc
make        |& tee om

#*
# (code-c-d "ruby186" "~/usrc/ruby-1.8.6/" :grep)
# (find-ruby186file "")
# (find-ruby186file "misc/")
# (find-ruby186file "misc/rdebug.el")
# (find-ruby186grep "grep -nH -e rdebug $(find *)")
# (find-ruby186sh   "find * | sort")

# (find-ruby186file "eval.c")
# (find-ruby186tag "rb_f_require")
# (find-ruby186tag "rb_require_safe")

# (find-ruby186file "class.c" "mod.instance_methods(include_super=true)")

# (find-ruby186file "eval.c" "\"require\"")
# (find-ruby186grep "grep -nH -e rb_features $(cat .files.ch)")
# (find-ruby186grep "grep -nH -e '\"methods\"' $(cat .files.ch)")
# (find-ruby186file "eval.c" "$LOADED_FEATURES")
# (find-rubymanualfile "")
# (find-rubymanualw3m "variable.html#dquote")
# (find-rubymanualw3m "function.html")

# (find-rubyri "lambda")
# (find-rubyri "Proc")
# (find-rubyri "Object")
# (find-rubyri "methods")

square = lambda   { |x| x*x }
square = Proc.new { |x| x*x }
square(5)
#^ NoMethodError: undefined method `square' for main:Object
def square (x) x*x end
square(5)

another newbie question... I'm looking for a low-level equivalent to, say "def square (x) x*x end" (just to understand how things work)... "square = Proc.new { |x| x*x }" doesn't do it, global functions and global variables live in different places... where can I find the semantics for what "def square (x) x*x end" and "square(5)" do?

define_method(:square)({ |x| x*x })



#####
#
# Basic classes
# 2007apr27
#
#####

Class.superclass   #-> Module
Module.superclass  #-> Object
Hash.superclass    #-> Object
Object.superclass  #-> nil
Proc.superclass    #-> Object

Module.methods

methods
singleton_methods
protected_methods
private_methods
public_methods
instance_variables

# (find-rubyri "methods")
# (find-rubyri "singleton_methods")
# (find-rubyri "protected_methods")
# (find-rubyri "private_methods")
# (find-rubyri "public_methods")
# (find-rubyri "instance_variables")

# (find-rubywayw3m "ch11lev1sec3.html")
# (find-rubywayw3m "ch11lev1sec3.html" "Dynamic Features")

# (find-rubyri "inject")






#####
#
# parsetree
# 2007apr27
#
#####

# http://on-ruby.blogspot.com/2006/12/rubinius-interview.html
# http://rubyforge.org/frs/download.php/17502/ParseTree-1.7.0.gem
# http://rubyforge.org/frs/download.php/17501/ParseTree-1.7.0.tgz





#####
#
# ruby-debug
# 2007apr27
#
#####

# http://www.datanoise.com/articles/2007/4/3/ruby-debug-version-0-9-1-has-been-released
sudo gem in ruby-debug |& tee /tmp/ogrd

ruby-debug
ruby-debug-base




#####
#
# gems from ruby
# 2007apr27
#
#####

# «gem»  (to ".gem")
# (find-man "1 gem")
# (find-sh "gem help commands")
# (find-sh "gem help examples")
# (find-sh "gem list")
# (find-sh "gem help contents")
# (find-sh "gem contents ruby-debug")
# (find-sh "gem contents ruby-debug -l")
# (find-sh "gem contents ruby-debug-base")
# http://rubygems.rubyforge.org
# http://rubygems.rubyforge.org/wiki/wiki.pl?CreateAGemInTenMinutes
# http://docs.rubygems.org/read/book/1

# (find-fline "/usr/bin/gem")

* (eepitch-ruby)
$LOADED_FEATURES
require 'rubygems'
$LOADED_FEATURES
Gem
Gem.class
Gem.methods
Gem.methods.sort
String.methods.sort
Array.methods.sort

# (find-status   "rubygems")
# (find-vldifile "rubygems.list")
# (find-udfile   "rubygems/")

# (find-rubyri "set_trace_func")
# (find-fline "/var/lib/gems/1.8/")
# (find-fline "/usr/lib/ruby/1.8/rubygems.rb")
# (find-progruby2page (+ 28 207) "gem environment gemdir")
# (find-progruby2text            "gem environment gemdir")




#####
#
# gem_server
#
#####

# «gem_server»  (to ".gem_server")
# (find-progruby2page (+ 28 208) "% gem_server")
# (find-progruby2text            "% gem_server")

* (eepitch-shell)
gem_server
# http://localhost:8808/


# (find-fline "/usr/bin/gem_server")
/usr/share/man/man1/gem_server.1.gz





#####
#
# gems
# 2006jul04
#
#####

# «gems-from-debian-source»  (to ".gems-from-debian-source")
# «gems-debian-repository»  (to ".gems-debian-repository")
# <ibroadfo> edrx42: add these lines to sources.list:
# <ibroadfo> #rubygems stuff
# <ibroadfo> deb     http://www.sgtpepper.net/hyspro/deb unstable/
# <ibroadfo> deb-src http://www.sgtpepper.net/hyspro/deb unstable/
#
# http://www.sgtpepper.net/hyspro/deb/
# Note that this is a simplified repository with the Packages file in
# the same dir as the debs...
# (find-zsh "gethrefs < $S/http/www.sgtpepper.net/hyspro/deb/unstable/index.html")
#
# http://www.sgtpepper.net/hyspro/deb/unstable/libgems-ruby_0.8.11-2.diff.gz
# http://www.sgtpepper.net/hyspro/deb/unstable/libgems-ruby_0.8.11-2.dsc
# http://www.sgtpepper.net/hyspro/deb/unstable/libgems-ruby_0.8.11.orig.tar.gz

# (code-c-d "gemssrc"   "~/usrc/gems/")
# (code-c-d "gemsbuild" "~/usrc/gems/libgems-ruby-0.8.11/")
# (find-gemssrcfile   "")
# (find-gemsbuildfile "")
#*
apti dpatch docbook-to-man

#*
rm -Rv ~/usrc/gems/
mkdir  ~/usrc/gems/
cd     ~/usrc/gems/
cp -iv $S/http/www.sgtpepper.net/hyspro/deb/unstable/libgems-ruby_* \
  ~/usrc/gems/

dpkg-source -sn -x libgems-ruby_0.8.11-2.dsc
cd     ~/usrc/gems/libgems-ruby-0.8.11/

dpkg-buildpackage -us -uc -b -rfakeroot		|& tee odb

#*
sudo dpkg -i ~/usrc/gems/*.deb

#*
# (find-status   "libgems-ruby1.8")
# (find-vldifile "libgems-ruby1.8.list")
# (find-udfile   "libgems-ruby1.8/")
# (find-status   "rubygems")
# (find-vldifile "rubygems.list")
# (find-udfile   "rubygems/")

# (find-fline "/usr/bin/gem")
# (find-fline "/usr/bin/gem_server")
# (find-fline "/usr/bin/gemwhich")
# (find-fline "/usr/bin/generate_yaml_index")
# (find-man "1 gemwhich")
# (find-man "1 generate_yaml_index")
# (find-man "1 gem")
# (find-man "1 gem_server")

# (find-sh "gem -h")
# (find-sh "gem help install")
# (find-sh "gem help install" "--install-dir /var/lib/gems/1.8")





####
#
# ruby-postgres-0.7.1 (older)
# 2006jul07
#
#####

# Maybe this one doesn't have the bad symbol...
# http://ruby.scripting.ca/postgres/archive/ruby-postgres-0.7.1.tar.gz
# (find-fline "~/usrc/ruby-postgres-0.7.1/")
# (code-c-d "rubypostgres" "~/usrc/ruby-postgres/")
# (code-c-d "rubypostgres" "~/usrc/ruby-postgres-0.7.1/")
# (find-rubypostgresfile "")
# (find-rubypostgresfile "om")
# (find-rubypostgresfile "om" "implicit declaration of function `PQserverVersion'")
#*
rm -Rv ~/usrc/ruby-postgres-0.7.1/
tar -C ~/usrc/ -xvzf \
  $S/http/ruby.scripting.ca/postgres/archive/ruby-postgres-0.7.1.tar.gz
cd     ~/usrc/ruby-postgres-0.7.1/

# (find-rubypostgresfile "extconf.rb")
POSTGRES_INCLUDE=/usr/include/postgresql \
ruby extconf.rb |& tee ore
make            |& tee om
make -n install |& tee omni
etags *.c

#*
cd ~/usrc/ruby-postgres-0.7.1/sample/
RUBYLIB=.. ruby psql.rb
RUBYLIB=.. ruby psql.rb edrxdb
RUBYLIB=.. ruby psql.rb -l

#*
# Same error as in 20051221:
# psql.rb:1132:in `initialize': FATAL:  IDENT authentication failed for user "edrx" (PGError)










#####
#
# ruby-postgres, without gems
# 2006jul06
#
#####

# «ruby-postgres»  (to ".ruby-postgres")
# (find-gemsvlgpgfile "postgres-ruby.gemspec")
# http://ruby.scripting.ca/postgres/
# http://ruby.scripting.ca/postgres/archive/ruby-postgres-20051221.tar.gz
# http://ruby.scripting.ca/postgres/rdoc/
# (find-fline "~/usrc/ruby-postgres/")
# (code-c-d "rubypostgres" "~/usrc/ruby-postgres/")
# (find-rubypostgresfile "")
# (find-rubypostgresfile "om" "implicit declaration of function `PQserverVersion'")
# (find-rubypostgresfile "postgres.c" "PQserverVersion(conn)")
# (find-rubypostgresfile "postgres.c" "PQserverVersion(get_pgconn(obj))")
# (find-pgexfile "")
# (find-pgexfile "testlibpq.c")
#*
rm -Rv ~/usrc/ruby-postgres/
tar -C ~/usrc/ -xvzf \
  $S/http/ruby.scripting.ca/postgres/archive/ruby-postgres-20051221.tar.gz
cd     ~/usrc/ruby-postgres/

ruby extconf.rb |& tee ore
make            |& tee om
make -n install |& tee omni

etags *.c *.h

#*
# (find-rubypostgresfile "")
# (find-rubypostgresfile "sample/psql.rb")
# (find-rubypostgresfile "sample/")
# (find-rubymanualw3m "function.html#require")
# (find-rubysrctag "require")
# (find-sh "ri1.8 require")
# (find-man "1 ruby")
# (find-man "1 ruby" "RUBYLIB")

cd ~/usrc/ruby-postgres/
cd ~/usrc/ruby-postgres/sample/
RUBYLIB=.. ruby psql.rb edrxdb
RUBYLIB=.. ruby psql.rb
RUBYLIB=.. ruby psql.rb -l

#*
# (find-es "postgres")
# (find-es "postgres" "libpq-upstream")
# (find-pgexfile "")
# (find-pgexfile "testlibpq.c")

cd ~/usrc/ruby-postgres/sample/
RUBYLIB=.. ruby test1.rb

#*




#####
#
# running ruby under gdb
# 2006jul06
#
#####

# «ruby-postgres-test1»  (to ".ruby-postgres-test1")
# «ruby-postgres-gdb»  (to ".ruby-postgres-gdb")
# (find-pgexfile "")
# (find-pgexfile "testlibpq.c")
# (find-pgexfile "testlibpq.c" "conninfo =")
# (find-rubypostgresfile "sample/test1.rb")
# (find-rubypostgresfile "postgres.c")
# (find-rubypostgresfile "postgres.c" "\"connect\"")
# (find-rubypostgresfile "postgres.c" "pgconn_s_new")
# (find-rubysrctag "rb_define_singleton_method")
# (find-rubysrcfile "math.c" "math_sin")
# (find-rubysrcfile "")
# (find-rubyfile "odb" "-o ruby1.8")
# (find-rubysrcfile "main.c")

# (find-rubyfile "odb" " -g ")
# (find-rubyfile "odb" "dh_strip -Xlibruby1.8-dbg")
# (find-man "1 dh_strip")

# (find-status   "libruby1.8-dbg")
# (find-vldifile "libruby1.8-dbg.list")
# (find-udfile   "libruby1.8-dbg/")

# (find-rubysrcfile "")

# (find-fline "/usr/lib/debug/libruby1.8.so.1.8.2")
# (find-udfile "libruby1.8-dbg/NEWS.Debian.gz")
# (find-udfile "libruby1.8-dbg/changelog.gz")
# (find-udfile "libruby1.8-dbg/copyright")
# (find-udfile "libruby1.8-dbg/changelog.Debian.gz")
# (find-fline "/usr/lib/debug/libruby1.8.so")
# (find-fline "/usr/lib/debug/libruby1.8.so.1.8")

# (find-fline "~/usrc/ruby/ruby1.8-1.8.2/build-tree/ruby-1.8.2/bin/irb")
# gdb ~/usrc/ruby/ruby1.8-1.8.2/build-tree/ruby-1.8.2/bin/irb

#*
# (eev-bounded)
cd ~/usrc/ruby-postgres/sample/
cat > /tmp/foo.rb <<'---'
  require '../postgres.so'
  Math.sin(0)     # because math_sin is a good place for a breakpoint
  conn = PGconn.connect("localhost", nil, nil, nil, "template1")
---

#*
# (find-rubypostgresfile "postgres.c" "pgconn_s_new")
# (find-rubysrcfile "math.c" "math_sin")

#*
# (ee-once (eeb-rubysrcgdb-start "ruby1.8"))
# Give preference to the .so with debugging symbols:
# (find-rubysrcfile "")
set env LD_LIBRARY_PATH /home/edrx/usrc/ruby/ruby1.8-1.8.2/build-tree/ruby-1.8.2::

# Because we might need stuff from that dir, and postgres.so is at ../ there:
cd ~/usrc/ruby-postgres/sample/

# Defined above: (find-fline "/tmp/foo.rb")
set args /tmp/foo.rb

# Walk past the "ruby_init()" function, that loads lots of libs:
# (find-rubysrcfile "main.c" "ruby_init()")
tbr main
run
next

# "Math.sin(0)" will cross the math_sin breakpoint...
# Show the list of shared libs to let us be sure that ../postgres.so is loaded
# PROBLEM: "info share" at this point doesn't show postgres.so -
# maybe because of something involving threads?
tbr math_sin
info share
cont

#*
# (ee-once (eegdb-bounded))
# (find-ebuffer "*gud-ruby1.8*")
# (find-rubypostgresfile "tests/tc_postgres.rb" "@conn = PGconn.new")
# (find-rubypostgresfile "postgres.c" "pgconn_s_new")

info share
br pgconn_alloc
cont

#*






#####
#
# ruby-postgres - building with gems (abandoned)
# 2006jul04
#
#####

# «ruby-postgres-gems»  (to ".ruby-postgres-gems")
# «postgres-from-ruby»  (to ".postgres-from-ruby")
# Note: gems is scary blackbox.
# Use this instead: (to "ruby-postgres")
# (find-zsh "acse ruby | sort")
# (find-zsh "acse postgres | sort")
# http://wiki.rubyonrails.org/rails/pages/PostgreSQL
# http://docs.rubygems.org/
# http://docs.rubygems.org/read/chapter/2
# http://docs.rubygems.org/read/chapter/2#page8
#*
# (find-fline "/usr/include/postgresql/")
apti postgresql-dev

#*
rm -Rv /tmp/gem/
mkdir  /tmp/gem/
cd     /tmp/gem/
gem install postgres |& tee ogip

#*
# (find-sh "gem help install" "--install-dir /var/lib/gems/1.8")
# (find-fline "~/usrc/gems/vlg-1.8/")
# (find-fline "~/usrc/gems/vlg-1.8/ogip")

rm -Rv ~/usrc/gems/vlg-1.8/
mkdir  ~/usrc/gems/vlg-1.8/
cd     ~/usrc/gems/vlg-1.8/
POSTGRES_INCLUDE=/usr/include/postgresql \
gem install postgres \
  --install-dir $PWD \
  |& tee ogip-local

#*
# Install the postgres gems globally:
cd ~/usrc/gems/vlg-1.8/
POSTGRES_INCLUDE=/usr/include/postgresql \
  sudo gem install postgres |& tee ogip

#*
# (find-sh "gem help")
# (find-sh "gem help commands")
# (find-sh "gem help specification")

# Doesn't work:
gem specification postgres -i ~/usrc/gems/vlg-1.8/

It seems that there is a config file somewhere, though.

#*

From #ruby-lang, 2006jul06:

<edrx> newbie question about gems... I've just built the support for
       postgres using gems, using the instructions in
       <http://wiki.rubyonrails.org/rails/pages/PostgreSQL>; my logs
       and scripts are at
       <http://angg.twu.net/e/ruby.e.html#postgres-from-ruby>. I'm
       keeping the gems at a non-standard directory in "~", namely, in
       ~/usrc/gems/vlg-1.8/ instead of in /var/lib/gems-1.8/; how do I
       tell Ruby to search for gems there instead of in the standard
       place?
<slyphon> edrx: mwuhahaha!
<slyphon> edrx: good luck with that
<teferi> slyphon: any packaging system that can't handle that is a
         disgusting hackj
<teferi> I don't like gems anymore
<edrx> O_o
<slyphon> teferi: yes, rubygems are a disgusting hack
<slyphon> teferi: this is common knowledge :)
<slyphon> teferi: i never use them, if i can help it
<teferi> slyphon: smart man
<teferi> debian packages of ruby libs come slowly, but they WORK
<slyphon> i download dependent libs and i check them into the
          repository alongside my code
<edrx> ok, I'll try to use a symlink from /var/lib/... ro ~/usrc/...
       then
<teferi> and if they don't, well, I make my own with checkinstall
<teferi> (checkinstall is awesome, btw)
<edrx> teferi: I compiled the debian package for gems locally and
       installed the debs...
<slyphon> i didn't think there *was* an official debian gems package
<edrx> what is checkinstall? url?
<apeiros> hm, I often hear that rubygems wasn't good this and wasn't
          good that - but never concrete reasons what is bad about
          rubygems - anybody cares to explain/elaborate?
<slyphon> apeiros: require 'rubygems'
<teferi> slyphon: there isn't and won't be, i thought
<teferi> because debian thinks gems are hacky and bad
<edrx> slyphon: I don't know how official it is...
       http://angg.twu.net/e/ruby.e.html#gems-from-debian-source
<apeiros> slyphon, um, yes? and now?
<slyphon> apeiros: it's non transparent, setting them up in a non-root
          location is harder than it should be, setting them to look
          in alternate paths for gems is difficult





#####
#
# getting rid of the "parsearg is deprecated" error without changing /usr
# 2006jul07
#
#####

Warning:psql.rb:20: parsearg is deprecated after Ruby 1.8.1; use optparse instead
Warning:/usr/lib/ruby/1.8/parsearg.rb:17: getopts is deprecated after Ruby 1.8.1; use optparse instead
# (find-fline "/usr/lib/ruby/1.8/parsearg.rb")

any tricks with path?

gem install postgres-pr




#####
#
# postgres-pr / gems are tar files
# 2006jul07
#
#####

# «gems-are-tar-files»  (to ".gems-are-tar-files")
# «postgres-pr»  (to ".postgres-pr")
# http://rubyforge.org/frs/download.php/3858/postgres-pr-0.4.0.gem
# (code-c-d "postgrespr" "~/usrc/postgres-pr-0.4.0/d/")
# (find-postgresprfile "")
# (find-postgresprfile "../metadata.gz")
#*
rm -Rv   ~/usrc/postgres-pr-0.4.0/
mkdir -p ~/usrc/postgres-pr-0.4.0/d/
tar -C   ~/usrc/postgres-pr-0.4.0/ -xvf \
  $S/http/rubyforge.org/frs/download.php/3858/postgres-pr-0.4.0.gem
tar -C   ~/usrc/postgres-pr-0.4.0/d/ \
  -xvzf  ~/usrc/postgres-pr-0.4.0/data.tar.gz
cd       ~/usrc/postgres-pr-0.4.0/d/

#*
# (find-postgresprfile "")
# (find-postgresprfile "examples/test_connection.rb")
# (find-postgresprfile "lib/postgres-pr/postgres-compat.rb" "tcp://")
# (find-postgresprfile "lib/postgres-pr/")




#####
#
# postgres-pr: connecting to a local (Debian) postgres server via socket
# 2006jul07
#
#####

# «postgres-pr-test»  (to ".postgres-pr-test")
# (find-es "net" "nmap")
# (find-sh "nmap 127.0.0.1")
# (find-postgresprfile "examples/test_connection.rb")
# (find-postgresprfile "lib/postgres-pr/connection.rb" "database, user,")
# (find-postgresprfile "lib/postgres-pr/connection.rb" "tcp://localhost:5432")
# (find-postgresprfile "lib/postgres-pr/connection.rb" "unix:/tmp/.s.PGSQL.5432")
# (find-es "postgres" "commands_on_edrxdb")
# (find-es "postgres" "psql-prefers-socket:log")

* (eepitch-shell)
irb
  $LOAD_PATH.unshift '/home/edrx/usrc/postgres-pr-0.4.0/d/lib'
  require 'postgres-pr/connection'
  conn = PostgresPR::Connection.new('edrxdb', 'edrx', nil, 'tcp://localhost:5432')
  conn = PostgresPR::Connection.new('edrxdb', 'edrx', nil, 'tcp://127.0.0.1:5432')
  conn = PostgresPR::Connection.new('edrxdb', 'edrx', nil,
           'unix:/var/run/postgresql/.s.PGSQL.5432')
  exit

# (find-man "irb")

# When I try to connect via tcp I get this error:
#   RuntimeError: FATAL C28000 MIDENT authentication failed for user
#   "edrx" Fauth.c L395 Rauth_failed




#####
#
# question about postgres-pr, tcp and MIDENT (for IRC channels)
# 2006jul10
#
#####

# «postgres-pr-mident-error»  (to ".postgres-pr-mident-error")

I'm not sure how to phrase that (I'm a newbie, btw) but well, lemme
try to ask it anyway before spending hours reading psql's source and
the API docs... I've ran this with "sudo -u postgres psql template1":
"CREATE USER edrx CREATEDB NOCREATEUSER; CREATE DATABASE edrxdb;" -
and now I'm able to run "psql edrxdb" as edrx, create tables, work on
them, etc etc. But I need to acess the tables in the database "edrxdb"
from Ruby, and I'm using a Ruby lib called postgres-pr ("pr" = "pure
ruby") that knows how to talk with postgres via tcp...

so - in Ruby I'm running "conn = PostgresPR::Connection.new('edrxdb',
'edrx', nil, 'tcp://localhost:5432')", where the order of arguments is
"database, user, password, uri", and I'm getting this error:

RuntimeError: FATAL C28000 MIDENT authentication failed for user
"edrx" Fauth.c L395 Rauth_failed

I don't understand how passwords and auths work in Postgres and I
would like to learn only the minimum about that at this point... any
pointers or suggestions?

# There's a hint here, but it's like "use unix sockets" without any
# further explanations... and I will need to access remote postgres
# servers in a near future.
# http://wiki.rubyonrails.org/rails/pages/PostgreSQL

# (find-fline "$ASROOT/etc/postgresql/pg_hba.conf")

# (find-pghtmlw3m "client-authentication-problems.html")
# (find-pghtmlw3m "client-authentication.html")
# (find-pghtmlw3m "client-interfaces.html")



#####
#
# mident problem: single-stepping through psql
# 2006jul10
#
#####

# «mident-error-gdb-psql»  (to ".mident-error-gdb-psql")
# (find-es "postgres" "gdb-ing-psql")
# (find-es "postgres" "postgres-upstream")
# (find-pgfile "src/bin/psql/")
# (find-pgfile "src/bin/psql/command.c" "\ndo_connect")
# (find-pggrep "grep -nH -e connect src/bin/psql/*.c")
# (find-psqlfile "")





#####
#
# LOAD_PATH
# 2006jul10
#
#####

# «LOAD_PATH»  (to ".LOAD_PATH")
# (find-rubysrcfile "eval.c" "absolute path")
# (find-sh "ri1.8 require")
# (find-man "1 ruby")
# (find-man "1 ruby" "RUBYLIB")
# (find-rubymanualw3m "variable.html#load_path")
# (find-rubymanualw3m "syntax.html#gvar" "$foobar")
# (find-postgresprfile "examples/test_connection.rb")

* (eechannel-xterm "A")
RUBYLIB=$RUBYLIB:$HOME/usrc/postgres-pr-0.4.0/d/lib/ \
  irb
$LOAD_PATH

require





#####
#
# mongrel
# 2006jul04
#
#####

# «mongrel»  (to ".mongrel")
# http://mongrel.rubyforge.org/
# http://mongrel.rubyforge.org/docs/index.html
# (find-zsh "dmissing mongrel")





#####
#
# edrxinit: postgres-pr
# 2006jul12
#
#####

# «edrxinit:postgres-pr»  (to ".edrxinit:postgres-pr")
# (find-angg ".ruby/edrxinit.rb")

# (find-sh "gem help")
# (find-sh "gem help commands")
# (find-sh "gem search postgres")
# (find-sh "gem list postgres-pr")

* (eepitch-shell)
sudo gem install postgres-pr




gem postgres-pr

* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
require 'postgres-pr/connection'
conn = PostgresPR::Connection.new('edrxdb', 'edrx', nil, ENV['PGSOCKET'])




* (eepitch-shell)
irb
  p conn = edrxdbconnect()
  exit




#####
#
# The Pragmatic Programmer's Guide
# 2006aug14
#
#####

# «pragmatic»  (to ".pragmatic")
# (find-angg ".emacs.papers" "ruby")
# (find-angg ".emacs" "ruby-pragmatic")
# http://www.flazx.com/
# (find-pdfpage-pdftotext "~/tmp/ruby-pragmatic-2nd-ed.pdf")
# (find-fline "~/tmp/ruby-pragmatic-2nd-ed.txt")
cd ~/tmp/
pdftotext -layout ~/tmp/ruby-pragmatic-2nd-ed.pdf

# (find-pragmaticrubypage 1)
# (find-pragmaticrubypage 34)
# (find-pragmaticrubypage (+ 28 222))
# (find-pragmaticrubytext "    Ruby and the Web")
# (find-pragmaticrubytext "    Query Parameters")
# (find-pragmaticrubytext "cgi.out {")



#####
#
# Ruby in a Nutshell (by Matz)
# 2007may08
#
#####

# «ruby-in-a-nutshell»  (to ".ruby-in-a-nutshell")
# http://sharespot.flazx.net/ebooks/0596002149.zip
# (find-angg ".emacs.papers" "ruby")
# (find-man "unzip")
#*
unzip -p $S/http/sharespot.flazx.net/ebooks/0596002149.zip \
  0596002149.pdf > /var/www/tmp/ruby-in-a-nutshell.pdf
#*
# (code-ps        "rubynutshell" "/var/www/tmp/ruby-in-a-nutshell.pdf")
# (code-pdftotext "rubynutshell" "/var/www/tmp/ruby-in-a-nutshell.pdf")
# (find-rubynutshellpage 31)
# (find-rubynutshellpage 45 "When a method is called,")
# (find-rubynutshelltext    "When a method is called, Ruby searches for it")
# (find-rubynutshelltext)
# (find-rubynutshelltext "Module#include")




#####
#
# el4r
# 2006aug18
#
#####

# «el4r»  (to ".el4r")
# http://www.rubyist.net/~rubikitch/computer/el4r/index.en.html
# http://www.rubyist.net/~rubikitch/archive/el4r-1.0.3.tar.gz
# http://www.emacswiki.org/cgi-bin/wiki/EmacsLispForRuby
# (code-c-d "el4r" "~/usrc/el4r-1.0.3/")
# (find-el4rfile "")
# (find-el4rfile "ors")
# (find-el4rfile "ors" "Permission denied - /usr/bin/el4r-instance")
# (find-el4rfile "setup.rb")
#*
rm -Rv ~/usrc/el4r-1.0.3/
tar -C ~/usrc/ -xvzf $S/http/www.rubyist.net/~rubikitch/archive/el4r-1.0.3.tar.gz
cd     ~/usrc/el4r-1.0.3/
ruby setup.rb |& tee ors

#*

4 Start and Restart el4r

To start or restart el4r, type

M-x el4r-boot

in Emacs. After you installed el4r and restart emacs, el4r is already
starting. You have to restart el4r when behavior becomes strange or
you rewrite init.rb.




#####
#
# el4r, langhelp and ruby-pkg-tools from the Debian sources
# 2006aug18
#
#####

# http://alysse.dyndns.org/~bdaix/debian/packages/unstable/
# http://alysse.dyndns.org/~bdaix/debian/packages/unstable/Packages
# http://alysse.dyndns.org/~bdaix/debian/packages/unstable/index.html
# http://alysse.dyndns.org/~bdaix/debian/packages/unstable/el4r_1.0.2-2.diff.gz
# http://alysse.dyndns.org/~bdaix/debian/packages/unstable/el4r_1.0.2-2.dsc
# http://alysse.dyndns.org/~bdaix/debian/packages/unstable/el4r_1.0.2.orig.tar.gz
# http://alysse.dyndns.org/~bdaix/debian/packages/unstable/langhelp_0.9.7-1.diff.gz
# http://alysse.dyndns.org/~bdaix/debian/packages/unstable/langhelp_0.9.7-1.dsc
# http://alysse.dyndns.org/~bdaix/debian/packages/unstable/langhelp_0.9.7.orig.tar.gz
# http://ftp.debian.org/debian/pool/main/r/ruby-pkg-tools/
# http://ftp.debian.org/debian/pool/main/r/ruby-pkg-tools/ruby-pkg-tools_0.10.dsc
# http://ftp.debian.org/debian/pool/main/r/ruby-pkg-tools/ruby-pkg-tools_0.10.tar.gz
#*
rm -Rv ~/usrc/el4r/
mkdir  ~/usrc/el4r/
cd     ~/usrc/el4r/
cp -v $S/http/ftp.debian.org/debian/pool/main/r/ruby-pkg-tools/ruby-pkg-tools_0.10* .
cp -v $S/http/alysse.dyndns.org/~bdaix/debian/packages/unstable/el4r_1.0.2* .
cp -v $S/http/alysse.dyndns.org/~bdaix/debian/packages/unstable/langhelp_0.9.7* .
dpkg-source -sn -x ruby-pkg-tools_0.10.dsc
dpkg-source -sn -x el4r_1.0.2-2.dsc
dpkg-source -sn -x langhelp_0.9.7-1.dsc

#*
cd ~/usrc/el4r/ruby-pkg-tools-0.10/
dpkg-buildpackage -us -uc -b -rfakeroot   |& tee odb

#*
cd ~/usrc/el4r/el4r-1.0.2/
dpkg-buildpackage -us -uc -b -rfakeroot   |& tee odb

#*
cd ~/usrc/el4r/langhelp-0.9.7/
dpkg-buildpackage -us -uc -b -rfakeroot   |& tee odb

#*
#  (find-fline "~/usrc/el4r/")
sudo dpkg -i ~/usrc/el4r/ruby-pkg-tools_0.10_all.deb
sudo dpkg -i ~/usrc/el4r/el4r_1.0.2-2_all.deb
sudo dpkg -i ~/usrc/el4r/langhelp_0.9.7-1_all.deb

#*
# (find-status   "ruby-pkg-tools")
# (find-vldifile "ruby-pkg-tools.list")
# (find-udfile   "ruby-pkg-tools/")
# (find-status   "el4r")
# (find-vldifile "el4r.list")
# (find-udfile   "el4r/")
# (find-status   "langhelp")
# (find-vldifile "langhelp.list")
# (find-udfile   "langhelp/")

# (find-fline "/usr/bin/el4r-instance")
# (find-fline "/usr/bin/el4r-rctool")
# (find-fline "/usr/bin/el4r-runtest")
# (find-fline "/usr/bin/el4r")
# (find-fline "/usr/lib/ruby/1.8/el4r/el4r-sub.rb")
# (find-fline "/usr/lib/ruby/1.8/el4r/exec-el4r.rb")
# (find-fline "/usr/lib/ruby/1.8/el4r/emacsruby/el4r-mode.rb")
# (find-fline "/usr/lib/ruby/1.8/el4r/emacsruby/stdlib.rb")
# (find-fline "/usr/lib/ruby/1.8/el4r/emacsruby/autoload/70el4r-mode.rb")
# (find-fline "/usr/lib/emacsen-common/packages/install/el4r")
# (find-fline "/usr/lib/emacsen-common/packages/remove/el4r")
# (find-fline "/usr/share/emacs/site-lisp/el4r.el")
# (find-udfile "el4r/BUGS")
# (find-udfile "el4r/el4r.en.html")







#####
#
# more
# 2006jul05
#
#####

# (find-rubybookw3m "tut_classes.html" "Song#new")
# (find-rubybookw3m "tut_classes.html")

What's the difference between # and ::?

# (find-rubybookw3m "tut_classes.html" "Writable Attributes")

class Song
  def duration=(newDuration)
    @duration = newDuration
  end
end

class Song
  attr_writer :duration
end


# (find-rubybookw3m "tut_classes.html" "person2 = person1.dup")

person = "Tim"
person.id       #->  537684980
person.type     #->  String
person          #->  "Tim"

# (find-rubybookw3m "tut_containers.html" "9, nil, 99")
# (find-rubybookw3m "tut_containers.html" "def threeTimes")

What is the default argument for yield (like a $_)?

Are there functions in Ruby that take more than one block as
"arguments"?

# (find-rubybookw3m "ref_c_file.html#open")




#####
#
# ruby-mode.el
# 2007apr13
#
#####

# «ruby-mode.el»  (to ".ruby-mode.el")
# (find-zsh "dmissing ruby-mode.el")
# (find-status   "ruby1.8-elisp")
# (find-vldifile "ruby1.8-elisp.list")
# (find-udfile   "ruby1.8-elisp/")




#####
#
# test/unit
# 2007apr13
#
#####

# «test.unit»  (to ".test.unit")
# (find-zsh "dmissing test/unit")
# (find-fline "/usr/lib/ruby/1.8/test/")
# (find-fline "/usr/lib/ruby/1.8/test/unit/")

# (find-status   "libruby1.8")
# (find-vldifile "libruby1.8.list")
# (find-udfile   "libruby1.8/")






#####
#
# ruby-manual (installing on etch the one from sarge)
# 2007apr20
#
#####

# «ruby-manual»  (to ".ruby-manual")
# It's obsolete...
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=210002
# http://packages.debian.org/ruby-manual
# http://packages.debian.org/cgi-bin/search_contents.pl?searchmode=filelist&word=ruby-manual&version=oldstable&arch=all&page=1&number=all
# http://ftp.debian.org/debian/pool/main/r/ruby-manual/
# http://ftp.debian.org/debian/pool/main/r/ruby-manual/ruby-manual_1.4.6-2.dsc
# http://ftp.debian.org/debian/pool/main/r/ruby-manual/ruby-manual_1.4.6-2_all.deb
# http://www.guadalinex.org/debian/pool/main/r/ruby-manual/

# (find-status   "ruby-manual")
# (find-vldifile "ruby-manual.list")
# (find-udfile   "ruby-manual/")
/usr/share/doc/ruby-manual/html

# (find-rubymanualw3m "Class.html")
# (find-rubymanualw3m "syntax.html#variable")

# (find-zsh "dmissing ruby | grep syntax")




#####
#
# rdoc
# 2007apr25
#
#####

# «rdoc»  (to ".rdoc")
# http://www.ruby-doc.org/core/classes/RDoc.html
# http://en.wikibooks.org/wiki/Ruby_Programming/RubyDoc

# (find-status   "rdoc1.8")
# (find-vldifile "rdoc1.8.list")
# (find-udfile   "rdoc1.8/")

# (find-status   "ri")
# (find-vldifile "ri.list")
# (find-udfile   "ri/")
# (find-vldifile "ri1.8.list")
# (find-udfile   "ri1.8/")

# (find-rubywayfile "")
# (find-rubywayw3m "Y.html")

# (find-sh "ri1.8 GC::enable")

(defun find-rubyri (name &rest rest)
  (apply 'find-sh (format "PAGER=cat ri1.8 %s" name) rest))

;; (find-rubyri "Test::Unit")
;; (find-fline "/usr/lib/ruby/1.8/test/unit/")
;; (find-fline "/usr/lib/ruby/1.8/test/unit.rb")




#####
#
# anonymous classes
# 2007may04
#
#####

# «anonymous-classes»  (to ".anonymous-classes")
# (find-rubyri "String#replace")
# (find-rubymanualw3m "")
# (find-rubymanualw3m "syntax.html")

* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
foo = "foo"
bar = "bar"
class << bar
  def wrap
    "<" + self + ">"
  end
end

foo               #-> "foo"
foo.wrap          #-> NoMethodError: undefined method `wrap' for "foo":String
bar               #-> "bar"
bar.wrap          #-> "<bar>"
bar.replace "BAR" #-> "BAR"
bar.wrap          #-> "<BAR>"

foo.class
bar.class


* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
foo = "foo"
bar = "bar"
foo.class.object_id
bar.class.object_id
foo.class.equal? bar.class
class << bar; def wrap; "<" + self + ">" end; end
foo.class
bar.class
foo.class.equal? bar.class

# maybe ".class" is the wrong method for what I want... does it skip
# anonymous classes? I would expect the "low-level class" of bar to
# change after the "class << bar ... end" thing below:

foo = "foo"
bar = "bar"
class << bar; def wrap; "<" + self + ">" end; end


foo = "foo"
bar = "bar"
foo.class.object_id
bar.class.object_id
foo.class.equal? bar.class
class << bar; def wrap; "<" + self + ">" end; end





#####
#
# singleton_class
# 2007may04
#
#####

# «singleton_class»  (to ".singleton_class")
# (find-fline "~/LOGS/")
# (find-fline "~/LOGS/2007may04.ruby-lang")
# (find-fline "~/LOGS/2007may04.ruby-lang" "def singleton_class")
# http://www.rubypal.com/i0nas.txt
# http://oldrcrs.rubypal.com/rcr/show/231

# (find-es "ruby" "singleton_class")
class Object; def singleton_class; class << self; self; end; end; end

* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
class Object; def singleton_class; class << self; self; end; end; end
foo = "foo"
bar = "bar"
foo.class
foo.class.object_id
foo.singleton_class
foo.singleton_class.object_id
bar.class
bar.class.object_id
bar.singleton_class
bar.singleton_class.object_id
class << bar; def wrap; "<" + self + ">" end; end
bar.class
bar.class.object_id
bar.singleton_class
bar.singleton_class.object_id


bar.class.object_id
foo.class.equal? bar.class
foo.class
bar.class
foo.class.equal? bar.class



# http://www.ruby-doc.org/docs/ProgrammingRuby/
# http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_classes.html#UF
# http://www.ruby-doc.org/docs/ProgrammingRuby/html/ref_m_kernel.html




* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
foo = "foo"
foo.methods.sort.join " "
foo.methods.sort.join ' '

foo.class === bar.class
foo.class === bar.class   #-> false - but why?

# (find-rubyri "String")
# (find-rubyri "replace")
# (find-rubyri "equal?")
# (find-rubyri "object_id")
# (find-rubyri "class")







Você pode me ajudar a visualizar o que acontece quando a o baktodo.rb
faz isso aqui?

  class MountPoint
    class << self
      alias_method :__new__, :new
      ...
    end
    ...
  end

Eu estou tentando ver uma classe como uma estrutura (no sentido "C"
mesmo), mas não está claro pra mim quais são os dados que ela
contém... a definição de "struct RClass" em ruby.h é minúscula; alguns
outputs dessas expressões aqui abaixo deveriam me dar uma nocão do que
ela tem dentro, mas como é que eu distinguo os métodos que estão
guardados na prória classe dos que são herdados da superclasse, e
quais dessas listas de nomes são uniões de outras?...

  k = Array

  k.methods.sort.grep(/method/)  .join " "
  k.methods.sort.grep(/instance/).join " "
  k.methods.sort.grep(/var/)     .join " "

  k.                   methods.sort.join " "
  k.            public_methods.sort.join " "
  k.           private_methods.sort.join " "
  k.          instance_methods.sort.join " "
  k.         protected_methods.sort.join " "
  k.         singleton_methods.sort.join " "
  k.   public_instance_methods.sort.join " "
  k.  private_instance_methods.sort.join " "
  k.protected_instance_methods.sort.join " "

Obs: é, eu podia ter ido te perguntar tudo isso direto, mas achei que
as minhas dúvidas ficariam mais claras se eu as escrevesse...

  [], Eduardo



http://en.wikipedia.org/wiki/Metaclass







http://wiki.rubygarden.org/Ruby/page/show/RubyOnIRC



<chrislo> edrx: the matrix class has an inverse method. require
          'matrix'
<edrx> chrislo: I'll try that later. thanks!
<chrislo> edrx: there's also nArray and Ruby/GSL for interface into
          the gnu scientific library.
<chrislo> edrx: recipe 2.11 in Ruby Cookbook if you can get hold of a
          copy !

<twb> ctags 5.6 alleges to support ruby
<twb> Sorry, make that exuberant-ctags
<twb> aptitude search ~d[ce]tags~druby





#####
#
# klass and super
# 2007may08
#
#####

# «klass-and-super»  (to ".klass-and-super")
Diagrams (in the "Programming Ruby" book):
(find-progruby2page (+ 28 363) "A basic object, with its class and superclass")
(find-progruby2page (+ 28 364) "Adding a metaclass to Guitar")

In (find-rubyri "Class")
we have a picture like this (I rearranged it a bit, and
added an "obj" created with "obj = OtherClass.new"):

                                             ++=====++
                                             /\     ||
                               Object---->(Object)  ||
                               /\  /\     /\ /\     ||
                               ||  ||     || ||     ||
             ++================++  ||     || ||     ||
             ||           ++==============++ ||     ||
             ||           ||       ||        ||     ||
obj-->  OtherClass-->(OtherClass)  ||        ||     ||
                                   ||        ||     ||
                                Module--->(Module)  ||
                                   /\        /\     ||
               /\                  ||        ||     ||
    .superclass||                  ||        ||     ||
               ||                Class---->(Class)  ||
                ------->           /\               ||
                .class             ||               \/
                                   ++===============++

This looks like the picture in:
  (find-progruby2page (+ 28 363))
From the point of view of the interpreter in C, the arrows going to
the right are ".klass", and the (double) arrows going up are ".super".

(find-rubysrcfile "ruby.h" "struct RBasic ")


* (eepitch-ruby)
Module.superclass   #-> Object
Object.superclass   #-> nil
Object.class        #-> Class

The "class" method skips virtual classes - if o.klass is a virtual
class then o.class returns o.klass.super, or o.klass.super.super,
etc - the first of these that doesn't have the "virtual" bit set.

# More pointers...
# (find-fline "~/LOGS/2007may04.ruby-lang" "|class << self;|")
# http://www.rubypal.com/i0nas.txt
# http://oldrcrs.rubypal.com/rcr/show/231

Objects with virtual classes:

foo = "foo"          # foo---------->String
bar = "bar"          # bar---------->String
class << bar         # bar-->(bar)-->String
  def wrap
    "<"..self..">"
  end
end

Subclasses:
                  # Object-->(Object)   
		  #  /\        /\     
		  #  ||        ||     
class Bar	  # Bar------>(Bar)   
end		  #  /\        /\	    
class Foo < Bar	  #  ||        ||     
end		  # Foo------>(Foo)   

# (find-progruby2text "A Ruby object has three components:")

  A Ruby object has three components: a set of flags, some instance
  variables, and an associated class. A Ruby class is an object of
  class Class, which contains all the object things plus a list of
  methods and a reference to a superclass (which is itself another
  class). All method calls in Ruby nominate a receiver (which is by
  default self, the current object). Ruby finds the method to invoke
  by looking at the list of methods in the receiver's class. If it
  doesn't find the method there, it looks in any included modules,
  then in its superclass, modules in the superclass, and then in the
  superclass's superclass, and so on. If the method cannot be found in
  the receiver's class or any of its ancestors, Ruby invokes the
  method method_missing on the original receiver.

  And that's it--the entire explanation. On to the next chapter.

Modules:





#####
#
# evil.rb
# 2007may09
#
#####

# «evil.rb»  (to ".evil.rb")
# http://eigenclass.org/hiki/evil.rb-wants-love
# http://eigenclass.org/hiki/class+hierarchy+introspection+evil.rb
# http://rubyforge.org/frs/download.php/19209/evil-ruby-0.1.0.gem
# http://rubyforge.org/frs/download.php/19210/evil-ruby-0.1.0.tgz
#*
rm -Rv ~/usrc/evil-ruby-0.1.0/
tar -C ~/usrc/ -xvzf \
  $S/http/rubyforge.org/frs/download.php/19210/evil-ruby-0.1.0.tgz
cd     ~/usrc/evil-ruby-0.1.0/

#*
# (code-c-d "evilruby" "~/usrc/evil-ruby-0.1.0/" :grep)
# (find-evilrubyfile "")
# (find-sh "gem help commands")
# (find-sh "gem help examples")
# (find-sh "gem help install")
# (find-sh "gem list")
# (find-sh "gem help contents")

* (eepitch-shell)
sudo gem install \
  $S/http/rubyforge.org/frs/download.php/19209/evil-ruby-0.1.0.gem

* (eepitch-shell)
cd ~/usrc/evil-ruby-0.1.0/
ruby1.8 test/tc_all.rb 
#
#   1) Error:
# test_force_bind():
# RangeError: 0x5be27420 is not id value
#
# (find-evilrubyfile "")
# (find-evilrubygrep "grep -nH -e force $(find *)")

# (find-evilrubyfile "")
# (find-evilrubyfile "lib/evil.rb")
# (find-evilrubyfile "lib/evil.rb" "RClass =")
# (find-evilrubyfile "lib/evil.rb" "def internal_class")

* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
require "rubygems"
require "evil"
class Bar; end
module Moo; end
class Foo < Bar
  include Moo
end
Foo.internal
Foo.internal.super
Bar.internal

RubyInternal.internal
RubyInternal.internal.m_tbl
String.internal
String.internal.m_tbl
String.internal.iv_tbl




#####
#
# require (for gems)
# 2007may09
#
#####

# (find-progruby2page 1)
# (find-progruby2page (+ 28 172))
# (find-progruby2page (+ 28 203))
# (find-progruby2page 1)

# (find-sh "ruby -e 'puts $:'")
# (find-sh "ruby -e 'require \"rubygems\"; puts $:'")

# (find-progruby2page (+ 28 207) "gem environment gemdir")
# (find-sh "gem environment gemdir")






#####
#
# open4
# 2007may09
#
#####

* (eepitch-shell)
sudo gem install open4

# (find-fline "/var/lib/gems/1.8/")
# (code-c-d "rubyopen4" "/var/lib/gems/1.8/gems/open4-0.9.3/")
# (find-rubyopen4file "")




#####
#
# methods for assignment
# 2007may09
#
#####

# (find-fline "~/LOGS/2007may09.ruby-lang")

<edrx> newbie question... when I do "foo = bar", which method is
       called? is there a method that receives an Lvalue for foo and
       the value of bar and does something? I'm still puzzled as to
       how assignment is dealt with in ruby... pointers welcome (I
       have the "programming ruby" and matz's "in a nutshell" book,
       and also the C source, "ri", and lots of stuff)
<teferi> edrx: when you say foo = bar, where foo is just a local
         variable, NO method is called
<edrx> teferi: ok... what about the other cases?
<teferi> edrx: ditto if foo is an instance variable, class variable,
         constant, or global variable
<teferi> edrx: if you say foo.bar = quux, it calls method bar= on
         object foo, passing it object quux as an argument
<teferi> if you say foo[bar] = quux, it calls method []= on foo,
         passing it arguments bar and quux
<teferi> that's about it





#####
#
# ruby-mysql
# 2007may11
#
#####

# «ruby-mysql»  (to ".ruby-mysql")
# (find-zsh "dmissing -i ruby | grep -i sql")
# (find-status   "libmysql-ruby1.8")
# (find-vldifile "libmysql-ruby1.8.list")
# (find-udfile   "libmysql-ruby1.8/")
# (find-udfile "libmysql-ruby1.8/examples/")
# (find-udfile "libmysql-ruby1.8/examples/test.rb.gz")
# (find-udw3m  "libmysql-ruby1.8/README.html")

# (find-sh "objdump -Tt /usr/lib/ruby/1.8/i486-linux/mysql.so")
# (find-man "1 objdump")

# http://ftp.debian.org/debian/pool/main/m/mysql-ruby/
# http://ftp.debian.org/debian/pool/main/m/mysql-ruby/mysql-ruby_2.7.1-1.dsc
# http://ftp.debian.org/debian/pool/main/m/mysql-ruby/mysql-ruby_2.7.1-1.diff.gz
# http://ftp.debian.org/debian/pool/main/m/mysql-ruby/mysql-ruby_2.7.1.orig.tar.gz
#*
rm -Rv ~/usrc/mysql-ruby/
mkdir  ~/usrc/mysql-ruby/
cd $S/http/ftp.debian.org/debian/pool/main/m/mysql-ruby/
cp -v mysql-ruby_2.7.1* ~/usrc/mysql-ruby/
cd     ~/usrc/mysql-ruby/
dpkg-source -sn -x mysql-ruby_2.7.1-1.dsc
cd     ~/usrc/mysql-ruby/mysql-ruby-2.7.1/
dpkg-buildpackage -us -uc -b -rfakeroot     |& tee odb

#*
# (code-c-d "mysqlruby" "~/usrc/mysql-ruby/mysql-ruby-2.7.1/")
# (find-mysqlrubyfile "")
# (find-mysqlrubyfile "mysql.c" "rb_define_class(\"Mysql\", rb_cObject);")

# Is the debian package above equivalent to this?
# (find-baksrvw3m "doc/files/README.html" "urpmi ruby ruby-rubygems ruby-mysql")
# (find-baksrvfile "baktodo-edrx.rb")
# (find-baksrvfile "baktodo-edrx.rb" "def mysql_xfs_snapshot")




#####
#
# multiline-comments
# 2019jun25
#
#####

# «multiline-comments» (to ".multiline-comments")
# (find-angg ".emacs" "ee-itest-ruby")
# https://www.quora.com/How-do-you-write-a-multi-line-comment-in-Ruby
# https://www.rubyguides.com/2019/02/ruby-comments-explained/



#####
#
# require (and load)
# 2019jun25
#
#####

# «require» (to ".require")
# (find-rubynutshellpage 62 "load( file[, private=false])")
# (find-rubynutshelltext 62 "load( file[, private=false])")
# (find-rubynutshellpage 63 "require( lib)")
# (find-rubynutshelltext 63 "require( lib)")

# (find-pragmaticrubypage (+ 28 762) "Index")
# (find-pragmaticrubypage (+ 28 780) "load")
# (find-pragmaticrubypage (+ 28 117) "load")
# (find-pragmaticrubytext "")



#####
#
# topological-sort
# 2019jun25
#
#####

# «topological-sort» (to ".topological-sort")
# https://rosettacode.org/wiki/Topological_sort#Ruby
# http://ruby-doc.org/stdlib-2.6.3/libdoc/tsort/rdoc/TSort.html
# (find-fline "/usr/share/ri/2.3.0/system/TSort/")



#####
#
# learnxinyminutes
# 2020dec18
#
#####

# «learnxinyminutes»  (to ".learnxinyminutes")
# https://github.com/adambard/learnxinyminutes-docs/blob/master/ruby.html.markdown




#####
#
# functions
# 2020dec18
#
#####

# «functions»  (to ".functions")
# (find-books "__comp/__comp.el" "pragmaticruby")
# (find-pragmaticrubypage (+ 28 47) "def fib_up_to(max)")
# (find-pragmaticrubytext (+ 28 47) "def fib_up_to(max)")

* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
def square(x)
  return x*x
end

square(2)

def square(x) return x*x*10 end
square(2)




#####
#
# irb-options
# 2021dec28
#
#####

# «irb-options»  (to ".irb-options")
# (find-man "irb")

* (eepitch-ansiterm)
* (eepitch-kill)
* (eepitch-ansiterm)

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)

* (eepitch-sh)
* (eepitch-kill)
* (eepitch-sh)
irb --noecho --simple-prompt --nomultiline --nosingleline --nocolorize
2 + 3;
3 + 4;

4 + 5;



#####
#
# a-compiler-from-scratch
# 2022mar02
#
#####

# «a-compiler-from-scratch»  (to ".a-compiler-from-scratch")
# https://www.destroyallsoftware.com/screencasts/catalog/a-compiler-from-scratch ***




#####
#
# rsyntaxtree
# 2024oct11
#
#####

# «rsyntaxtree»  (to ".rsyntaxtree")
# https://yohasebe.com/rsyntaxtree/
# https://yohasebe.github.io/rsyntaxtree/examples
# https://github.com/yohasebe/rsyntaxtree
# (code-c-d "rsyntaxtree" "~/usrc/rsyntaxtree/")
# (find-rsyntaxtreefile "")



#####
#
# rbenv
# 2023feb18
#
#####

# «rbenv»  (to ".rbenv")





* (eepitch-ruby)
* (eepitch-kill)
* (eepitch-ruby)
foo = "foo"
foo.class
class << foo
  self
end
class << foo
  self
end

                      


                      





# (find-rubyri "class")
# (find-rubyri "include")
# (find-rubyri "append_features")
# (find-rubyri "Module#append_features")
# (find-rubyri "Module#include")
# (find-rubyri "Module#included")
# (find-rubysrcfile "")
# (find-rubysrcfile "eval.c" "\"include\"")
# (find-rubysrcfile "eval.c" "rb_mod_include(argc, argv, module)")
# (find-rubysrcgrep "grep -nH -e append_features *.c")



# (find-rubymanualfile "")
# (find-rubymanualw3m "syntax.html#cdef")


http://www.slideshare.net/yukihiro_matz/how-emacs-changed-my-life

http://joshstaiger.org/archives/2006/12/of_closures_met_1.html
http://tryruby.hobix.com/
http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptable-lisp
https://github.com/fullofcaffeine/org-catalog-ebooks

http://tomayko.com/writings/unicorn-is-unix

https://www.ruby-toolbox.com/

That website basically lists projects by use case and
help you find out which ones are the most popular,
up to date and so on.

https://github.com/readme/featured/why-the-lucky-stiff

https://news.ycombinator.com/item?id=29272682 Where is Ruby Headed in 2021? (bignerdranch.com) ***
https://news.ycombinator.com/item?id=30622266 How to Use Lambdas in Ruby (2020) (scoutapm.com)
https://news.ycombinator.com/item?id=31567755 Show HN: Shale – a Ruby object mapper and serializer for JSON, YAML and XML (shalerb.org)
https://news.ycombinator.com/item?id=33790568 Dynamic types have the potential to be more than "no static types" (buttondown.email/hillelwayne) - .source_location

https://jvns.ca/talks/
https://dev.to/baweaver/pattern-matching-interfaces-in-ruby-1b15
https://brightonruby.com/2022/stop-ignoring-pattern-matching-tom-stuart/
https://news.ycombinator.com/item?id=36184039 Rsh: Ruby SHell (github.com/isene)
https://blog.appsignal.com/2023/07/26/an-introduction-to-metaprogramming-in-ruby.html
https://news.ycombinator.com/item?id=37202714 Ruby's hash is a Swiss-army knife (akshaykhot.com)
https://blog.jez.io/inheritance-in-ruby/
https://railsatscale.com/2024-04-16-prism-in-2024/
https://news.ycombinator.com/item?id=40285244 Show HN: Visual debugger for Rails system tests (github.com/stepful)
https://lucasoshiro.github.io/posts-en/2024-06-17-ruby-shellscript/ Ruby: a great language for shell scripts!
https://news.ycombinator.com/item?id=40763640 Ruby: A great language for shell scripts (lucasoshiro.github.io)
https://zverok.space/blog/2024-07-26-range-evolution.html




#  Local Variables:
#  coding:               utf-8-unix
#  End: