[#33169] a cool Ruby script. — Yuji Asakawa <namu@...>

21 messages 2002/01/05

[#33229] ruby のインストールがうまくいかない — satoshi SAKAI <gau_sato@...9.dion.ne.jp>

はじめまして。

25 messages 2002/01/08
[#33230] Re: ruby のインストールがうまくいかない — shukaku@... 2002/01/08

At Tue, 8 Jan 2002 19:58:55 +0900,

[#33231] Re: ruby のインストールがうまくいかない — satoshi SAKAI <gau_sato@...9.dion.ne.jp> 2002/01/08

サカイです。

[#33233] Re: ruby のインストールがうまくいかない — nobu.nakada@... 2002/01/08

なかだです。

[#33254] Re: ruby のインストールがうまくいかない — satoshi SAKAI <gau_sato@...9.dion.ne.jp> 2002/01/09

サカイです。

[#33255] Re: ruby のインストールがうまくいかない — rubikitch <rubikitch@...> 2002/01/09

From: satoshi SAKAI <gau_sato@d9.dion.ne.jp>

[#33256] Re: ruby のインストールがうまくいかない — IWAOKA Masahiro <iwaoka@...> 2002/01/09

In the message <20020109102738.TQIO11600.femail11.im.home.ne.jp@witch>,

[#33235] " 差分ベースモジュール " in Ruby — Taku Nakajima <tnakajima@...>

中島@ブレーンです。

30 messages 2002/01/09
[#33238] Re: " 差分ベースモジュール " in Ruby — TADA Tadashi <sho@...> 2002/01/09

ただただしです。

[#33240] Re: " 差分ベースモジュール " in Ruby — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp> 2002/01/09

Toshです。

[#33241] Re: " 差分ベースモジュール " in Ruby — Tanaka Akira <akr@...17n.org> 2002/01/09

In article <A5EF3ECC-04BE-11D6-B67B-003065DC8B1C@yb3.so-net.ne.jp>,

[#33243] Re: " 差分ベースモジュール " in Ruby — Tanaka Akira <akr@...17n.org> 2002/01/09

In article <hvoell014rl.fsf@coulee.a02.aist.go.jp>,

[#33244] Re: " 差分ベースモジュール " in Ruby — matz@... (Yukihiro Matsumoto) 2002/01/09

まつもと ゆきひろです

[#33249] Re: " 差分ベースモジュール " in Ruby — Tanaka Akira <akr@...17n.org> 2002/01/09

In article <1010559765.279084.16212.nullmailer@ev.netlab.jp>,

[#33251] Re: " 差分ベースモジュール " in Ruby — matz@... (Yukihiro Matsumoto) 2002/01/09

まつもと ゆきひろです

[#33252] Re: " 差分ベースモジュール " in Ruby — Tanaka Akira <akr@...17n.org> 2002/01/09

In article <1010566232.053696.16272.nullmailer@ev.netlab.jp>,

[#33346] IPSocket.getaddress — "Sadayuki Sakamoto" <sakacom@...>

酒本です。

16 messages 2002/01/13

[#33416] No such file to load -- dbm — satoshi SAKAI <gau_sato@...9.dion.ne.jp>

サカイと言います。(以前もお世話になりました。)

13 messages 2002/01/17

[#33462] Re: Mysql/Ruby のコンパイル — "井上 浩一" <kyoui32@...>

井上です。

34 messages 2002/01/21
[#33463] Re: Mysql/Ruby のコンパイル — HIDAKA Takahiro <cv8t-hdk@...> 2002/01/21

 ひだかです。

[#33464] Re: Mysql/Ruby のコンパイル — nobu.nakada@... 2002/01/21

なかだです。

[#33465] Re: Mysql/Ruby のコンパイル — HIDAKA Takahiro <cv8t-hdk@...> 2002/01/21

 ひだかです。

[#33466] Re: Mysql/Ruby のコンパイル — nobu.nakada@... 2002/01/21

なかだです。

[#33467] Re: Mysql/Ruby のコンパイル — HIDAKA Takahiro <cv8t-hdk@...> 2002/01/21

 ひだかです。

[#33468] Re: Mysql/Ruby のコンパイル — nobu.nakada@... 2002/01/21

なかだです。

[#33471] Re: Mysql/Ruby のコンパイル — HIDAKA Takahiro <cv8t-hdk@...> 2002/01/22

 ひだかです。

[#33473] Re: Mysql/Ruby のコンパイル — nobu.nakada@... 2002/01/22

なかだです。

[#33474] Re: Mysql/Ruby のコンパイル — HIDAKA Takahiro <cv8t-hdk@...> 2002/01/22

 ひだかです。

[#33486] Re: Mysql/Ruby のコンパイル — "TAMURA.KENICHI" <sgs02516@...> 2002/01/22

たむらです。

[#33487] Re: Mysql/Ruby のコンパイル — nobu.nakada@... 2002/01/22

なかだです。

[#33488] Re: Mysql/Ruby のコンパイル — "TAMURA.KENICHI" <sgs02516@...> 2002/01/22

たむらです。

[#33477] about nest class — sheepman <sheepman@...>

こんにちは

21 messages 2002/01/22
[#33478] Re: about nest class — matz@... (Yukihiro Matsumoto) 2002/01/22

まつもと ゆきひろです

[#33517] [BUG] Can't compile ruby on Solaris2.6 — IWAMURO Motonori <iwa@...>

岩室です。

17 messages 2002/01/25
[#33518] Re: [BUG] Can't compile ruby on Solaris2.6 — matz@... (Yukihiro Matsumoto) 2002/01/25

まつもと ゆきひろです

[#33535] broken symbolic link and File::mtime — Go Nakagawa <nakagawa@...>

中川といいます。

37 messages 2002/01/25
[#33545] Re: broken symbolic link and File::mtime — matz@... (Yukihiro Matsumoto) 2002/01/25

まつもと ゆきひろです

[#33560] Re: broken symbolic link and File::mtime — Takahiro Kambe <taca@...> 2002/01/27

In message <1012002148.661980.9788.nullmailer@ev.netlab.jp>

[#33563] Re: broken symbolic link and File::mtime — Kazuhiro NISHIYAMA <zn@...> 2002/01/27

西山和広です。

[#33564] Re: broken symbolic link and File::mtime — Takahiro Kambe <taca@...> 2002/01/27

In message <20020127213735.2369.ZN@mbf.nifty.com>

[#33575] Re: broken symbolic link and File::mtime — Kazuhiro NISHIYAMA <zn@...> 2002/01/28

西山和広です。

[#33581] Re: broken symbolic link and File::mtime — matz@... (Yukihiro Matsumoto) 2002/01/28

まつもと ゆきひろです

[#33584] Re: broken symbolic link and File::mtime — Tanaka Akira <akr@...17n.org> 2002/01/28

In article <1012194192.456224.19148.nullmailer@ev.netlab.jp>,

[#33587] Re: broken symbolic link and File::mtime — matz@... (Yukihiro Matsumoto) 2002/01/28

まつもと ゆきひろです

[#33588] Re: broken symbolic link and File::mtime — Tanaka Akira <akr@...17n.org> 2002/01/28

In article <1012208486.646506.19793.nullmailer@ev.netlab.jp>,

[#33590] Re: broken symbolic link and File::mtime — matz@... (Yukihiro Matsumoto) 2002/01/28

まつもと ゆきひろです

[#33591] Re: broken symbolic link and File::mtime — Tanaka Akira <akr@...17n.org> 2002/01/28

In article <1012212090.162851.19949.nullmailer@ev.netlab.jp>,

[#33595] Re: broken symbolic link and File::mtime — matz@... (Yukihiro Matsumoto) 2002/01/28

まつもと ゆきひろです

[#33664] rd2 コマンド( RDtool )が動かない。 — Seiji Yoneda <yoneda@...>

米田と申します。はじめて投稿します。

24 messages 2002/01/30
[#33667] Re: rd2 コマンド( RDtool )が動かない。 — ARIMA Yasuhiro <fit0298@...> 2002/01/30

有馬です。

[ruby-list:33409] Re: cgi-ng ( Re: ruby-mode のインデント不具合 (} + の次の行))

From: nobu.nakada@...
Date: 2002-01-16 10:35:03 UTC
List: ruby-list #33409
なかだです。

あまりにもデカくなってしまったので、ruby-devに。

At Wed, 16 Jan 2002 16:20:14 +0900,
matz@ruby-lang.org (Yukihiro Matsumoto) wrote:
> できれば次世代CGIライブラリは
> 
>   require 'cgi-ng'
>   cgi = CGI.new('html4')
>   cgi.out {
>     cgi.html {
>       cgi.head {
>         cgi.title {'title'}
>       }
>       cgi.body {
>         cgi.h1 {'title'}
>         cgi.p {'contents'}
>       }
>     }
>   }
> 
> というインターフェースであってほしいものです。あるいは

こんな感じでしょうか。とりあえず上くらいの単純なものなら、今の
とだいたい同じ結果になりそうな気が。


Index: cgi.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/lib/cgi.rb,v
retrieving revision 1.33
diff -u -2 -p -r1.33 cgi.rb
--- cgi.rb	2001/11/21 03:30:22	1.33
+++ cgi.rb	2002/01/16 10:00:26
@@ -560,5 +560,6 @@ convert string charset, and set language
 
     options = { "type" => options } if options.kind_of?(String)
-    content = yield
+    yield
+    content = @content.join("\n") << "\n"
 
     if options.has_key?("charset")
@@ -584,4 +585,12 @@ convert string charset, and set language
   end
 
+  def <<(s)
+    if s and !s.empty?
+      @nest -= 1 if /\A<\// =~ s
+      @content << (@pretty and @nest > 0 ? (@pretty * @nest) << s : s)
+      @nest += 1 if /\A<[^!\/]/ =~ s and /\/>\z/ !~ s
+    end
+    self
+  end
 
 =begin
@@ -1000,5 +1009,7 @@ convert string charset, and set language
     def nn_element_def(element)
       <<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
-          "<element.upcase" + attributes.collect{|name, value|
+        def #{element.downcase}(attributes = {})
+          nest = @nest
+          self << "<element.downcase" + attributes.collect{|name, value|
             next unless value
             " " + CGI::escapeHTML(name) +
@@ -1008,11 +1019,12 @@ convert string charset, and set language
               '="' + CGI::escapeHTML(value) + '"'
             end
-          }.to_s + ">" +
+          }.to_s + ">"
           if block_given?
-            yield.to_s
-          else
-            ""
-          end +
-          "</element.upcase>"
+            self << yield
+          end
+          self << "</element.downcase>"
+          @nest = nest
+          ""
+        end
       END
     end
@@ -1021,5 +1033,6 @@ convert string charset, and set language
     def nOE_element_def(element)
       <<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
-          "<element.upcase" + attributes.collect{|name, value|
+        def #{element.downcase}(attributes = {})
+          self << "<element.downcase" + attributes.collect{|name, value|
             next unless value
             " " + CGI::escapeHTML(name) +
@@ -1030,4 +1043,6 @@ convert string charset, and set language
             end
           }.to_s + ">"
+          ""
+        end
       END
     end
@@ -1036,5 +1051,7 @@ convert string charset, and set language
     def nO_element_def(element)
       <<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
-          "<element.upcase" + attributes.collect{|name, value|
+        def #{element.downcase}(attributes = {})
+          nest = @nest
+          self << "<element.downcase" + attributes.collect{|name, value|
             next unless value
             " " + CGI::escapeHTML(name) +
@@ -1044,13 +1061,14 @@ convert string charset, and set language
               '="' + CGI::escapeHTML(value) + '"'
             end
-          }.to_s + ">" +
+          }.to_s + ">"
           if block_given?
-            yield.to_s + "</element.upcase>"
-          else
-            ""
+            self << yield
+            self << "</element.downcase>"
+            @nest = nest
           end
+          ""
+        end
       END
     end
-
   end # TagMaker
 
@@ -1191,15 +1209,14 @@ convert string charset, and set language
       values.collect{|value|
         if value.kind_of?(String)
-          checkbox(name, value) + value
+          checkbox(name, value)
+          self << value
+        elsif value[-1] == true
+          checkbox(name, value[0], true)
+          self << value[-2]
         else
-          if value[value.size - 1] == true
-            checkbox(name, value[0], true) +
-            value[value.size - 2]
-          else
-            checkbox(name, value[0]) +
-            value[value.size - 1]
-          end
+          checkbox(name, value[0])
+          self << value[-1]
         end
-      }.to_s
+      }
     end
 
@@ -1261,16 +1278,11 @@ The hash keys are case sensitive. Ask th
                      method
                    end
-      if block_given?
-        body = yield
-      else
-        body = ""
-      end
+      yield if block_given?
       if @output_hidden
-        hidden = @output_hidden.collect{|k,v|
-          "<INPUT TYPE=HIDDEN NAME=\"#{k}\" VALUE=\"#{v}\">"
-        }.to_s
-        body += hidden
+        @output_hidden.collect{|k,v|
+          self << "<input type=hidden name=\"#{k.downcase}\" value=\"#{v}\">"
+        }
       end
-      super(attributes){body}
+      super(attributes)
     end
 
@@ -1338,30 +1350,20 @@ The hash keys are case sensitive. Ask th
         attributes = { "PRETTY" => true }
       end
-      pretty = attributes.delete("PRETTY")
-      pretty = "  " if true == pretty
-      buf = ""
+      @pretty = attributes.delete("PRETTY")
+      @pretty = "  " if @pretty == true
 
       if attributes.has_key?("DOCTYPE")
-        if attributes["DOCTYPE"]
-          buf += attributes.delete("DOCTYPE")
-        else
-          attributes.delete("DOCTYPE")
+        if d = attributes.delete("DOCTYPE")
+          self << d
         end
       else
-        buf += doctype
+        self << doctype
       end
 
       if block_given?
-        buf += super(attributes){ yield }
-      else
-        buf += super(attributes)
-      end
-
-      if pretty
-        CGI::pretty(buf, pretty)
+        super(attributes){ yield }
       else
-        buf
+        super(attributes)
       end
-
     end
 
@@ -1516,17 +1518,15 @@ The hash keys are case sensitive. Ask th
         values.collect{|value|
           if value.kind_of?(String)
-            option({ "VALUE" => value }){ value }
+            option({ "VALUE" => value }){ self << value }
+          elsif value[-1] == true
+            option({ "VALUE" => value[0], "SELECTED" => true }){
+              self << value[-2]
+            }
           else
-            if value[value.size - 1] == true
-              option({ "VALUE" => value[0], "SELECTED" => true }){
-                value[value.size - 2]
-              }
-            else
-              option({ "VALUE" => value[0] }){
-                value[value.size - 1]
-              }
-            end
+            option({ "VALUE" => value[0] }){
+              self << value[-1]
+            }
           end
-        }.to_s
+        }
       }
 
@@ -1588,17 +1588,16 @@ The hash keys are case sensitive. Ask th
         name = name["NAME"]
       end
-      values.collect{|value|
+      values.each {|value|
         if value.kind_of?(String)
-          radio_button(name, value) + value
+          radio_button(name, value)
+          self << value
+        elsif value[-1] == true
+          radio_button(name, value[0], true)
+          self << value[-2]
         else
-          if value[value.size - 1] == true
-            radio_button(name, value[0], true) +
-            value[value.size - 2]
-          else
-            radio_button(name, value[0]) +
-            value[value.size - 1]
-          end
+          radio_button(name, value[0])
+          self << value[-1]
         end
-      }.to_s
+      }
     end
 
@@ -1718,6 +1717,31 @@ The hash keys are case sensitive. Ask th
   end # HtmlExtension
 
+  extend TagMaker
+  methods = ""
+
+  methods << nn_element_def("PRE").sub(/(\n\s+)self << yield/, '\1@nest = 0\&')
+
+  # - -
+  for element in %w[A ADDRESS B BIG BLOCKQUOTE CAPTION CITE CODE
+      DFN DIV DL EM FORM H1 H2 H3 H4 H5 H6 I KBD MAP OL SAMP
+      SCRIPT SELECT SMALL STRONG STYLE SUB SUP TABLE TEXTAREA
+      TITLE TT UL VAR]
+    methods << nn_element_def(element)
+  end
+
+  # - O EMPTY
+  for element in %w[AREA BASE BR HR IMG INPUT LINK META PARAM]
+    methods << nOE_element_def(element)
+  end
+
+  # O O or - O
+  for element in %w[HTML BODY P DT DD LI OPTION TR TH TD HEAD]
+    methods << nO_element_def(element)
+  end
+
+  eval(methods)
 
   module Html3
+    extend TagMaker
 
     def doctype
@@ -1725,46 +1749,27 @@ The hash keys are case sensitive. Ask th
     end
 
-    def element_init
-      extend TagMaker
-      methods = ""
-      # - -
-      for element in %w[ A TT I B U STRIKE BIG SMALL SUB SUP EM STRONG
-          DFN CODE SAMP KBD VAR CITE FONT ADDRESS DIV center MAP
-          APPLET PRE XMP LISTING DL OL UL DIR MENU SELECT table TITLE
-          STYLE SCRIPT H1 H2 H3 H4 H5 H6 TEXTAREA FORM BLOCKQUOTE
-          CAPTION ]
-        methods += <<-BEGIN + nn_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
+    methods = ""
 
-      # - O EMPTY
-      for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
-          ISINDEX META ]
-        methods += <<-BEGIN + nOE_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
+    # - -
+    for element in %w[APPLET center DIR FONT LISTING MENU STRIKE U XMP]
+      methods << nn_element_def(element)
+    end
 
-      # O O or - O
-      for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION tr
-          th td ]
-        methods += <<-BEGIN + nO_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
-      eval(methods)
+    # - O EMPTY
+    for element in %w[BASEFONT ISINDEX]
+      methods << nOE_element_def(element)
     end
 
+    # O O or - O
+    for element in %w[PLAINTEXT]
+      methods << nO_element_def(element)
+    end
+
+    eval(methods)
   end # Html3
 
 
   module Html4
+    extend TagMaker
 
     def doctype
@@ -1772,45 +1777,29 @@ The hash keys are case sensitive. Ask th
     end
 
-    def element_init
-      extend TagMaker
-      methods = ""
-      # - -
-      for element in %w[ TT I B BIG SMALL EM STRONG DFN CODE SAMP KBD
-        VAR CITE ABBR ACRONYM SUB SUP SPAN BDO ADDRESS DIV MAP OBJECT
-        H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT OPTGROUP
-        FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT
-        TEXTAREA FORM A BLOCKQUOTE CAPTION ]
-        methods += <<-BEGIN + nn_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
+    methods = ""
 
-      # - O EMPTY
-      for element in %w[ IMG BASE BR AREA LINK PARAM HR INPUT COL META ]
-        methods += <<-BEGIN + nOE_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
+    # - -
+    for element in %w[ABBR ACRONYM BDO BUTTON DEL FIELDSET INS LABEL
+        LEGEND NOSCRIPT OBJECT OPTGROUP Q SPAN]
+      methods << nn_element_def(element)
+    end
 
-      # O O or - O
-      for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
-          COLGROUP TR TH TD HEAD]
-        methods += <<-BEGIN + nO_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
-      eval(methods)
+    # - O EMPTY
+    for element in %w[COL]
+      methods << nOE_element_def(element)
+    end
+
+    # O O or - O
+    for element in %w[THEAD TFOOT TBODY COLGROUP]
+      methods << nO_element_def(element)
     end
 
+    eval(methods)
   end # Html4
 
 
   module Html4Tr
+    extend TagMaker
+    include Html4
 
     def doctype
@@ -1818,47 +1807,28 @@ The hash keys are case sensitive. Ask th
     end
 
-    def element_init
-      extend TagMaker
-      methods = ""
-      # - -
-      for element in %w[ TT I B U S STRIKE BIG SMALL EM STRONG DFN
-          CODE SAMP KBD VAR CITE ABBR ACRONYM FONT SUB SUP SPAN BDO
-          ADDRESS DIV CENTER MAP OBJECT APPLET H1 H2 H3 H4 H5 H6 PRE Q
-          INS DEL DL OL UL DIR MENU LABEL SELECT OPTGROUP FIELDSET
-          LEGEND BUTTON TABLE IFRAME NOFRAMES TITLE STYLE SCRIPT
-          NOSCRIPT TEXTAREA FORM A BLOCKQUOTE CAPTION ]
-        methods += <<-BEGIN + nn_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
+    methods = ""
 
-      # - O EMPTY
-      for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
-          COL ISINDEX META ]
-        methods += <<-BEGIN + nOE_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
+    # - -
+    for element in %w[APPLET CENTER DIR FONT IFRAME MENU NOFRAMES S
+        STRIKE U]
+      methods << nn_element_def(element)
+    end
 
-      # O O or - O
-      for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
-          COLGROUP TR TH TD HEAD ]
-        methods += <<-BEGIN + nO_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
-      eval(methods)
+    # - O EMPTY
+    for element in %w[BASEFONT ISINDEX META]
+      methods << nOE_element_def(element)
+    end
+
+    # O O or - O
+    for element in %w[]
+      methods << nO_element_def(element)
     end
 
+    eval(methods)
   end # Html4Tr
 
 
   module Html4Fr
+    extend TagMaker
 
     def doctype
@@ -1866,26 +1836,17 @@ The hash keys are case sensitive. Ask th
     end
 
-    def element_init
-      methods = ""
-      # - -
-      for element in %w[ FRAMESET ]
-        methods += <<-BEGIN + nn_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
+    methods = ""
 
-      # - O EMPTY
-      for element in %w[ FRAME ]
-        methods += <<-BEGIN + nOE_element_def(element) + <<-END
-          def #{element.downcase}(attributes = {})
-        BEGIN
-          end
-        END
-      end
-      eval(methods)
+    # - -
+    for element in %w[FRAMESET]
+      methods << nn_element_def(element)
+    end
+
+    # - O EMPTY
+    for element in %w[ FRAME ]
+      methods << nOE_element_def(element)
     end
 
+    eval(methods)
   end # Html4Fr
 
@@ -1907,22 +1868,19 @@ The hash keys are case sensitive. Ask th
     when "html3"
       extend Html3
-      element_init()
       extend HtmlExtension
     when "html4"
       extend Html4
-      element_init()
       extend HtmlExtension
     when "html4Tr"
       extend Html4Tr
-      element_init()
       extend HtmlExtension
     when "html4Fr"
       extend Html4Tr
-      element_init()
       extend Html4Fr
-      element_init()
       extend HtmlExtension
     end
 
+    @content = []
+    @nest = 0
   end
 


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread