Project

General

Profile

Feature #10175 » UseKernel#proc.PATCH

gogotanaka (Kazuki Tanaka), 08/27/2014 07:51 PM

View differences:

lib/cgi/session.rb
156 156
    attr_reader :session_id, :new_session
157 157

  
158 158
    def Session::callback(dbman)  #:nodoc:
159
      Proc.new{
159
      proc {
160 160
        dbman[0].close unless dbman.empty?
161 161
      }
162 162
    end
lib/irb/ruby-lex.rb
82 82
    elsif block_given?
83 83
      @input = block
84 84
    else
85
      @input = Proc.new{@io.gets}
85
      @input = proc { @io.gets }
86 86
    end
87 87
  end
88 88

  
......
197 197
    if p.respond_to?(:call)
198 198
      @prompt = p
199 199
    else
200
      @prompt = Proc.new{print p}
200
      @prompt = proc { print p }
201 201
    end
202 202
  end
203 203

  
......
352 352
    end
353 353

  
354 354
    @OP.def_rule("=begin",
355
                 proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
355
                 proc { |op, io| @prev_char_no == 0 && peek(0) =~ /\s/ }) do
356 356
      |op, io|
357 357
      @ltype = "="
358 358
      until getc == "\n"; end
......
471 471
      Token(TkOPASGN, $1)
472 472
    end
473 473

  
474
    @OP.def_rule("+@", proc{|op, io| @lex_state == EXPR_FNAME}) do
474
    @OP.def_rule("+@", proc { |op, io| @lex_state == EXPR_FNAME }) do
475 475
      |op, io|
476 476
      @lex_state = EXPR_ARG
477 477
      Token(op)
478 478
    end
479 479

  
480
    @OP.def_rule("-@", proc{|op, io| @lex_state == EXPR_FNAME}) do
480
    @OP.def_rule("-@", proc { |op, io| @lex_state == EXPR_FNAME }) do
481 481
      |op, io|
482 482
      @lex_state = EXPR_ARG
483 483
      Token(op)
......
599 599
      Token("~")
600 600
    end
601 601

  
602
    @OP.def_rule("~@", proc{|op, io| @lex_state == EXPR_FNAME}) do
602
    @OP.def_rule("~@", proc { |op, io| @lex_state == EXPR_FNAME }) do
603 603
      |op, io|
604 604
      @lex_state = EXPR_BEG
605 605
      Token("~")
......
619 619
      Token(tk_c)
620 620
    end
621 621

  
622
    @OP.def_rule("[]", proc{|op, io| @lex_state == EXPR_FNAME}) do
622
    @OP.def_rule("[]", proc { |op, io| @lex_state == EXPR_FNAME }) do
623 623
      |op, io|
624 624
      @lex_state = EXPR_ARG
625 625
      Token("[]")
626 626
    end
627 627

  
628
    @OP.def_rule("[]=", proc{|op, io| @lex_state == EXPR_FNAME}) do
628
    @OP.def_rule("[]=", proc { |op, io| @lex_state == EXPR_FNAME }) do
629 629
      |op, io|
630 630
      @lex_state = EXPR_ARG
631 631
      Token("[]=")
lib/matrix.rb
1109 1109
    size = row_count
1110 1110
    last = size - 1
1111 1111
    a = to_a
1112
    no_pivot = Proc.new{ return 0 }
1112
    no_pivot = proc { return 0 }
1113 1113
    sign = +1
1114 1114
    pivot = 1
1115 1115
    size.times do |k|
lib/rdoc/ruby_lex.rb
148 148
    elsif block_given?
149 149
      @input = block
150 150
    else
151
      @input = Proc.new{@io.gets}
151
      @input = proc { @io.gets }
152 152
    end
153 153
  end
154 154

  
......
265 265
    if p.respond_to?(:call)
266 266
      @prompt = p
267 267
    else
268
      @prompt = Proc.new{print p}
268
      @prompt = proc { print p }
269 269
    end
270 270
  end
271 271

  
......
430 430
    end
431 431

  
432 432
    @OP.def_rule("=begin",
433
                 proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
433
                 proc { |op, io| @prev_char_no == 0 && peek(0) =~ /\s/ }) do
434 434
      |op, io|
435 435
      @ltype = "="
436 436
      res = ''
......
556 556
      Token(TkOPASGN, $1)
557 557
    end
558 558

  
559
    @OP.def_rule("+@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
559
    @OP.def_rule("+@", proc { |op, io| @lex_state == :EXPR_FNAME }) do
560 560
      |op, io|
561 561
      @lex_state = :EXPR_ARG
562 562
      Token(op)
563 563
    end
564 564

  
565
    @OP.def_rule("-@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
565
    @OP.def_rule("-@", proc { |op, io| @lex_state == :EXPR_FNAME }) do
566 566
      |op, io|
567 567
      @lex_state = :EXPR_ARG
568 568
      Token(op)
......
690 690
      Token("~")
691 691
    end
692 692

  
693
    @OP.def_rule("~@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
693
    @OP.def_rule("~@", proc { |op, io| @lex_state == :EXPR_FNAME }) do
694 694
      |op, io|
695 695
      @lex_state = :EXPR_BEG
696 696
      Token("~")
......
710 710
      Token tk_c
711 711
    end
712 712

  
713
    @OP.def_rule("[]", proc{|op, io| @lex_state == :EXPR_FNAME}) do
713
    @OP.def_rule("[]", proc { |op, io| @lex_state == :EXPR_FNAME }) do
714 714
      |op, io|
715 715
      @lex_state = :EXPR_ARG
716 716
      Token("[]")
717 717
    end
718 718

  
719
    @OP.def_rule("[]=", proc{|op, io| @lex_state == :EXPR_FNAME}) do
719
    @OP.def_rule("[]=", proc { |op, io| @lex_state == :EXPR_FNAME }) do
720 720
      |op, io|
721 721
      @lex_state = :EXPR_ARG
722 722
      Token("[]=")
......
796 796
      end
797 797
    end
798 798

  
799
    #       @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
799
    #       @OP.def_rule("def", proc { |op, io| /\s/ =~ io.peek(0) }) do
800 800
    # 	|op, io|
801 801
    # 	@indent += 1
802 802
    # 	@lex_state = :EXPR_FNAME
lib/rss/0.9.rb
450 450
      @rss.do_validate = @do_validate
451 451
      @rss.xml_stylesheets = @xml_stylesheets
452 452
      @last_element = @rss
453
      pr = Proc.new do |text, tags|
453
      pr = proc do |text, tags|
454 454
        @rss.validate_for_stream(tags, @ignore_unknown_element) if @do_validate
455 455
      end
456 456
      @proc_stack.push(pr)
lib/rss/1.0.rb
474 474
      @rss.do_validate = @do_validate
475 475
      @rss.xml_stylesheets = @xml_stylesheets
476 476
      @last_element = @rss
477
      pr = Proc.new do |text, tags|
477
      pr = proc do |text, tags|
478 478
        @rss.validate_for_stream(tags, @ignore_unknown_element) if @do_validate
479 479
      end
480 480
      @proc_stack.push(pr)
lib/rss/atom.rb
815 815
      @rss.lang = attrs["xml:lang"]
816 816
      @rss.base = attrs["xml:base"]
817 817
      @last_element = @rss
818
      pr = Proc.new do |text, tags|
818
      pr = proc do |text, tags|
819 819
        @rss.validate_for_stream(tags) if @do_validate
820 820
      end
821 821
      @proc_stack.push(pr)
......
830 830
      @rss.lang = attrs["xml:lang"]
831 831
      @rss.base = attrs["xml:base"]
832 832
      @last_element = @rss
833
      pr = Proc.new do |text, tags|
833
      pr = proc do |text, tags|
834 834
        @rss.validate_for_stream(tags) if @do_validate
835 835
      end
836 836
      @proc_stack.push(pr)
lib/rss/maker/base.rb
501 501
      end
502 502

  
503 503
      [
504
       ["link", "href", Proc.new {|target,| "#{target}.href = 'self'"}],
504
       ["link", "href", proc { |target| "#{target}.href = 'self'" }],
505 505
       ["author", "name"],
506 506
       ["contributor", "name"],
507 507
      ].each do |name, attribute, additional_setup_maker|
......
715 715

  
716 716
        [
717 717
         ["author", "name"],
718
         ["link", "href", Proc.new {|target,| "#{target}.href = 'alternate'"}],
718
         ["link", "href", proc { |target| "#{target}.href = 'alternate'" }],
719 719
         ["contributor", "name"],
720 720
        ].each do |name, attribute|
721 721
          def_classed_elements(name, attribute)
lib/rss/parser.rb
327 327
                                        element_attrs)
328 328
        previous << next_element if previous
329 329
        @last_xml_element = next_element
330
        pr = Proc.new do |text, tags|
330
        pr = proc do |text, tags|
331 331
          if previous
332 332
            @last_xml_element = previous
333 333
          else
......
444 444
    end
445 445

  
446 446
    def start_get_text_element(tag_name, prefix, ns, required_uri)
447
      pr = Proc.new do |text, tags|
447
      pr = proc do |text, tags|
448 448
        setter = self.class.setter(required_uri, tag_name)
449 449
        if setter and @last_element.respond_to?(setter)
450 450
          if @do_validate
......
515 515
      @last_element.parent = previous if klass.need_parent?
516 516
      @xml_child_mode = @last_element.have_xml_content?
517 517

  
518
      Proc.new do |text, tags|
518
      proc do |text, tags|
519 519
        p(@last_element.class) if DEBUG
520 520
        if @xml_child_mode
521 521
          @last_element.content = @xml_element.to_s
......
540 540

  
541 541
    def setup_next_element_in_unknown_element
542 542
      current_element, @last_element = @last_element, nil
543
      Proc.new {@last_element = current_element}
543
      proc { @last_element = current_element }
544 544
    end
545 545
  end
546 546

  
lib/webrick/httprequest.rb
251 251
    # Returns the request body.
252 252

  
253 253
    def body(&block) # :yields: body_chunk
254
      block ||= Proc.new{|chunk| @body << chunk }
254
      block ||= proc { |chunk| @body << chunk }
255 255
      read_body(@socket, block)
256 256
      @body.empty? ? nil : @body
257 257
    end