ruby.rb 1.9 KB
Newer Older
1 2 3 4 5 6 7
if something_wrong?             # ruby-move-to-block-skips-heredoc
  ActiveSupport::Deprecation.warn(<<-eowarn)
  boo hoo
  end
  eowarn
end

8
# Percent literals.
9
b = %Q{This is a "string"}
10
c = %w!foo
11
 bar
12 13 14 15 16 17 18 19
 baz!
d = %(hello (nested) world)

# Don't propertize percent literals inside strings.
"(%s, %s)" % [123, 456]

# Or inside comments.
x = # "tot %q/to"; =
20
  y = 2 / 3
21 22 23 24 25 26

# Regexp after whitelisted method.
"abc".sub /b/, 'd'

# Don't mis-match "sub" at the end of words.
a = asub / aslb + bsub / bslb;
27

28 29
# Highlight the regexp after "if".
x = toto / foo if /do bar/ =~ "dobar"
30

31 32 33 34 35 36 37 38 39
bar(class: XXX) do              # ruby-indent-keyword-label
  foo
end
bar

foo = [1,                       # ruby-deep-indent
       2]

foo = {                         # ruby-deep-indent-disabled
40
  a: b
41 42 43 44 45 46 47 48 49 50
}

foo = [                         # ruby-deep-indent-disabled
  1
]

foo(                            # ruby-deep-indent-disabled
  a
)

51 52 53 54 55
# Multiline regexp.
/bars
 tees # toots
 nfoos/

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
def test1(arg)
  puts "hello"
end

def test2 (arg)
  a = "apple"

  if a == 2
    puts "hello"
  else
    puts "there"
  end

  if a == 2 then
    puts "hello"
  elsif a == 3
    puts "hello3"
  elsif a == 3 then
    puts "hello3"
  else
    puts "there"
  end

  case a
  when "a"
    6
82 83
  # Support for this syntax was removed in Ruby 1.9, so we
  # probably don't need to handle it either.
84 85 86 87 88 89 90 91
  # when "b" :
  #   7
  # when "c" : 2
  when "d"  then 4
  else 5
  end
end

92 93 94 95
# Some Cucumber code:
Given /toto/ do
  print "hello"
end
96 97 98 99 100

# Bug#15208
if something == :==
  do_something
end
101

102 103 104 105 106 107 108 109
begin
  foo
ensure
  bar
end

# Examples below fail with SMIE.

110 111
# Bug#15369
MSG = 'Separate every 3 digits in the integer portion of a number' \
112
      'with underscores(_).'
113 114 115 116 117 118 119 120 121 122 123 124 125

# Next two fail similarly to the one above, so maybe remove 1 or 2
# after they're fixed:

a = foo(j, k) -
  bar_tee

while a < b do # "do" is optional
  foo
end

desc "foo foo" \
  "bar bar"
126 127 128 129 130 131

foo.
  bar

foo
  .bar