rufo 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rufo/formatter.rb +44 -14
- data/lib/rufo/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5977c3bee92952a7125dfe7f6bc7dc64d9baa994
         | 
| 4 | 
            +
              data.tar.gz: 1abb73ee81dfa60272c6244d246a224ff9129ddb
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 5bb6a4ad522968388e50eaf6daa9257bc38f7d2b39864f78dd19127afdd0507afc0f6fead7023c971f045ab3207ae184f1494f134f006d6189ec2fae85a531ea
         | 
| 7 | 
            +
              data.tar.gz: cfeb8c85246bc916f57e311583df9bdf1c22770a70f7019cf80b2a1f6945ef067ba4f90d03aa069f31d3dfa75abb71f1b17ef171d086ebfdafb9926c7aa1be3d
         | 
    
        data/lib/rufo/formatter.rb
    CHANGED
    
    | @@ -170,6 +170,9 @@ class Rufo::Formatter | |
| 170 170 | 
             
                when :@ivar
         | 
| 171 171 | 
             
                  # [:@ivar, "@foo", [1, 0]]
         | 
| 172 172 | 
             
                  consume_token :on_ivar
         | 
| 173 | 
            +
                when :@cvar
         | 
| 174 | 
            +
                  # [:@cvar, "@@foo", [1, 0]]
         | 
| 175 | 
            +
                  consume_token :on_cvar
         | 
| 173 176 | 
             
                when :@const
         | 
| 174 177 | 
             
                  # [:@const, "FOO", [1, 0]]
         | 
| 175 178 | 
             
                  consume_token :on_const
         | 
| @@ -181,8 +184,14 @@ class Rufo::Formatter | |
| 181 184 | 
             
                  consume_op "::"
         | 
| 182 185 | 
             
                  skip_space_or_newline
         | 
| 183 186 | 
             
                  visit node[1]
         | 
| 187 | 
            +
                when :top_const_field
         | 
| 188 | 
            +
                  # [:top_const_field, [:@const, "Foo", [1, 2]]]
         | 
| 189 | 
            +
                  consume_op "::"
         | 
| 190 | 
            +
                  visit node[1]
         | 
| 184 191 | 
             
                when :const_path_ref
         | 
| 185 192 | 
             
                  visit_path(node)
         | 
| 193 | 
            +
                when :const_path_field
         | 
| 194 | 
            +
                  visit_path(node)
         | 
| 186 195 | 
             
                when :assign
         | 
| 187 196 | 
             
                  visit_assign(node)
         | 
| 188 197 | 
             
                when :opassign
         | 
| @@ -812,13 +821,7 @@ class Rufo::Formatter | |
| 812 821 |  | 
| 813 822 | 
             
              def visit_command_end(node, args)
         | 
| 814 823 | 
             
                push_call(node) do
         | 
| 815 | 
            -
                   | 
| 816 | 
            -
                    if args[0].is_a?(Symbol)
         | 
| 817 | 
            -
                      visit args
         | 
| 818 | 
            -
                    else
         | 
| 819 | 
            -
                      visit_exps args, false, false
         | 
| 820 | 
            -
                    end
         | 
| 821 | 
            -
                  end
         | 
| 824 | 
            +
                  visit_command_args(args)
         | 
| 822 825 | 
             
                end
         | 
| 823 826 |  | 
| 824 827 | 
             
                check_heredocs_at_call_end(node)
         | 
| @@ -869,15 +872,23 @@ class Rufo::Formatter | |
| 869 872 | 
             
                visit name
         | 
| 870 873 | 
             
                consume_space
         | 
| 871 874 |  | 
| 872 | 
            -
                 | 
| 873 | 
            -
                  visit args
         | 
| 874 | 
            -
                end
         | 
| 875 | 
            +
                visit_command_args(args)
         | 
| 875 876 |  | 
| 876 877 | 
             
                # Only set it after we visit the call after the dot,
         | 
| 877 878 | 
             
                # so we remember the outmost dot position
         | 
| 878 879 | 
             
                @dot_column = dot_column
         | 
| 879 880 | 
             
              end
         | 
| 880 881 |  | 
| 882 | 
            +
              def visit_command_args(args)
         | 
| 883 | 
            +
                indent(@column) do
         | 
| 884 | 
            +
                  if args[0].is_a?(Symbol)
         | 
| 885 | 
            +
                    visit args
         | 
| 886 | 
            +
                  else
         | 
| 887 | 
            +
                    visit_exps args, false, false
         | 
| 888 | 
            +
                  end
         | 
| 889 | 
            +
                end
         | 
| 890 | 
            +
              end
         | 
| 891 | 
            +
             | 
| 881 892 | 
             
              def visit_call_with_block(node)
         | 
| 882 893 | 
             
                # [:method_add_block, call, block]
         | 
| 883 894 | 
             
                _, call, block = node
         | 
| @@ -1100,8 +1111,10 @@ class Rufo::Formatter | |
| 1100 1111 | 
             
                if final_exp
         | 
| 1101 1112 | 
             
                  nodes = [*node[1], node[2]]
         | 
| 1102 1113 | 
             
                  visit_comma_separated_list(nodes)
         | 
| 1103 | 
            -
                 | 
| 1114 | 
            +
                elsif exps[0].is_a?(Symbol)
         | 
| 1104 1115 | 
             
                  visit exps
         | 
| 1116 | 
            +
                else
         | 
| 1117 | 
            +
                  visit_exps exps, false, false
         | 
| 1105 1118 | 
             
                end
         | 
| 1106 1119 | 
             
              end
         | 
| 1107 1120 |  | 
| @@ -1587,9 +1600,7 @@ class Rufo::Formatter | |
| 1587 1600 | 
             
                      visit elem
         | 
| 1588 1601 | 
             
                    end
         | 
| 1589 1602 |  | 
| 1590 | 
            -
                     | 
| 1591 | 
            -
                      check :on_words_sep
         | 
| 1592 | 
            -
             | 
| 1603 | 
            +
                    if !last?(i, elements) && current_token_kind == :on_words_sep
         | 
| 1593 1604 | 
             
                      # On a newline, write line and indent
         | 
| 1594 1605 | 
             
                      if current_token_value.include?("\n")
         | 
| 1595 1606 | 
             
                        next_token
         | 
| @@ -2424,6 +2435,12 @@ class Rufo::Formatter | |
| 2424 2435 | 
             
                    next_token
         | 
| 2425 2436 | 
             
                    last            = :comment
         | 
| 2426 2437 | 
             
                    multilple_lines = false
         | 
| 2438 | 
            +
                  when :on_embdoc_beg
         | 
| 2439 | 
            +
                    write_line if multilple_lines
         | 
| 2440 | 
            +
             | 
| 2441 | 
            +
                    consume_embedded_comment
         | 
| 2442 | 
            +
                    last = :comment
         | 
| 2443 | 
            +
                    last_comment_has_newline = true
         | 
| 2427 2444 | 
             
                  else
         | 
| 2428 2445 | 
             
                    break
         | 
| 2429 2446 | 
             
                  end
         | 
| @@ -2440,6 +2457,19 @@ class Rufo::Formatter | |
| 2440 2457 | 
             
                end
         | 
| 2441 2458 | 
             
              end
         | 
| 2442 2459 |  | 
| 2460 | 
            +
              def consume_embedded_comment
         | 
| 2461 | 
            +
                write current_token_value
         | 
| 2462 | 
            +
                next_token
         | 
| 2463 | 
            +
             | 
| 2464 | 
            +
                while current_token_kind != :on_embdoc_end
         | 
| 2465 | 
            +
                  write current_token_value
         | 
| 2466 | 
            +
                  next_token
         | 
| 2467 | 
            +
                end
         | 
| 2468 | 
            +
             | 
| 2469 | 
            +
                write current_token_value.rstrip
         | 
| 2470 | 
            +
                next_token
         | 
| 2471 | 
            +
              end
         | 
| 2472 | 
            +
             | 
| 2443 2473 | 
             
              def indent(value = nil)
         | 
| 2444 2474 | 
             
                if value
         | 
| 2445 2475 | 
             
                  old_indent = @indent
         | 
    
        data/lib/rufo/version.rb
    CHANGED