Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c7e83bd0d7a0
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ce2bc73ef0a6
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Feb 28, 2015

  1. Warn on block for String#lines

    "passing a block to String#lines is deprecated" is displayed when a
    block is used. MRI does this since 2.0.
    lumeet committed Feb 28, 2015
    Copy the full SHA
    85249b2 View commit details
  2. Merge pull request #2633 from lumeet/lines_with_block_deprecation

    Warn on block for String#lines
    nirvdrum committed Feb 28, 2015
    Copy the full SHA
    ce2bc73 View commit details
Showing with 10 additions and 5 deletions.
  1. +10 −4 core/src/main/java/org/jruby/RubyString.java
  2. +0 −1 test/mri/excludes/TestString.rb
14 changes: 10 additions & 4 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -5160,16 +5160,22 @@ public IRubyObject lines(ThreadContext context, IRubyObject arg, Block block) {

@JRubyMethod(name = "lines")
public IRubyObject lines20(ThreadContext context, Block block) {
if (block.isGiven()) {
context.runtime.getWarnings().warn("passing a block to String#lines is deprecated");
return each_lineCommon19(context, block);
}
// FIXME: Inefficient; build array manually rather than via Enumerator
return block.isGiven() ? each_lineCommon19(context, block) :
enumeratorize(context.runtime, this, "lines").callMethod(context, "to_a");
return enumeratorize(context.runtime, this, "lines").callMethod(context, "to_a");
}

@JRubyMethod(name = "lines")
public IRubyObject lines20(ThreadContext context, IRubyObject arg, Block block) {
if (block.isGiven()) {
context.runtime.getWarnings().warn("passing a block to String#lines is deprecated");
return each_lineCommon19(context, arg, block);
}
// FIXME: Inefficient; build array manually rather than via Enumerator
return block.isGiven() ? each_lineCommon19(context, arg, block) :
enumeratorize(context.runtime, this, "lines", arg).callMethod(context, "to_a");
return enumeratorize(context.runtime, this, "lines", arg).callMethod(context, "to_a");
}

private IRubyObject each_lineCommon19(ThreadContext context, Block block) {
1 change: 0 additions & 1 deletion test/mri/excludes/TestString.rb
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
exclude :test_count, "needs investigation"
exclude :test_dummy_inspect, "needs investigation"
exclude :test_eq_tilde_can_be_overridden, "needs investigation"
exclude :test_lines, "needs investigation"
exclude :test_partition, "needs investigation"
exclude :test_regexp_match_subclass, "String subclass with overridden =~ should see obj =~ dispatch (#2157)"
exclude :test_rpartition, "needs investigation"