lazibi 0.1.14 → 0.1.15
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.
- data/History.txt +7 -0
- data/Manifest.txt +5 -0
- data/Rakefile +2 -1
- data/config/lazibi_config.rb +15 -0
- data/lib/core/engine_base.rb +10 -10
- data/lib/filter/beautify_filter.rb +1 -1
- data/lib/filter/filter_base.rb +2 -2
- data/lib/filter/optional_do_filter.rb +2 -2
- data/lib/filter/optional_end_filter.rb +2 -2
- data/lib/helper/beautify_filter_helper.rb +2 -2
- data/lib/helper/filter_helper.rb +5 -4
- data/lib/helper/task_helper.rb +4 -4
- data/lib/lazibi.rb +1 -1
- data/lib/lazibi/version.rb +1 -1
- data/lib/task.rb +3 -3
- data/spec/core/beautify_engine_spec.rb +1 -1
- data/spec/core/default_engine_spec.rb +3 -3
- data/spec/core/engine_base_spec.rb +2 -2
- data/spec/filter/beautify_filter_spec.rb +5 -5
- data/spec/filter/optional_do_filter_spec.rb +5 -5
- data/spec/filter/optional_end_filter_spec.rb +56 -18
- data/spec/filter/syntax_guard_filter_spec.rb +1 -1
- data/spec/fixtures/beautify/metas/space_sep_do.txt +4 -0
- data/spec/fixtures/beautify/rbs/space_sep_do.txt +4 -0
- data/spec/fixtures/optional_end/metas/space_sep_do.txt +3 -0
- data/spec/fixtures/optional_end/rbs/space_sep_do.txt +4 -0
- data/spec/helper/filter_helper_spec.rb +4 -4
- data/spec/helper/task_helper_spec.rb +2 -2
- data/spec/lazibi_spec.rb +3 -4
- data/webgen/src/faq.page +2 -4
- metadata +47 -2
    
        data/History.txt
    CHANGED
    
    
    
        data/Manifest.txt
    CHANGED
    
    | @@ -5,6 +5,7 @@ Manifest.txt | |
| 5 5 | 
             
            README.txt
         | 
| 6 6 | 
             
            Rakefile
         | 
| 7 7 | 
             
            bin/lazibi
         | 
| 8 | 
            +
            config/lazibi_config.rb
         | 
| 8 9 | 
             
            config/lazibi_config_template.rb
         | 
| 9 10 | 
             
            lib/core/beautify_engine.rb
         | 
| 10 11 | 
             
            lib/core/default_engine.rb
         | 
| @@ -31,7 +32,9 @@ spec/filter/filter_spec_helper.rb | |
| 31 32 | 
             
            spec/filter/optional_do_filter_spec.rb
         | 
| 32 33 | 
             
            spec/filter/optional_end_filter_spec.rb
         | 
| 33 34 | 
             
            spec/filter/syntax_guard_filter_spec.rb
         | 
| 35 | 
            +
            spec/fixtures/beautify/metas/space_sep_do.txt
         | 
| 34 36 | 
             
            spec/fixtures/beautify/metas/square_brackets.txt
         | 
| 37 | 
            +
            spec/fixtures/beautify/rbs/space_sep_do.txt
         | 
| 35 38 | 
             
            spec/fixtures/beautify/rbs/square_brackets.txt
         | 
| 36 39 | 
             
            spec/fixtures/clean/comment_break.txt
         | 
| 37 40 | 
             
            spec/fixtures/clean/complex_string.txt
         | 
| @@ -73,6 +76,8 @@ spec/fixtures/optional_do/rbs/describe.txt | |
| 73 76 | 
             
            spec/fixtures/optional_do/rbs/do_block.txt
         | 
| 74 77 | 
             
            spec/fixtures/optional_do/rbs/lambda.txt
         | 
| 75 78 | 
             
            spec/fixtures/optional_do/rbs/square_brackets.txt
         | 
| 79 | 
            +
            spec/fixtures/optional_end/metas/space_sep_do.txt
         | 
| 80 | 
            +
            spec/fixtures/optional_end/rbs/space_sep_do.txt
         | 
| 76 81 | 
             
            spec/fixtures/real/basic_class.txt
         | 
| 77 82 | 
             
            spec/fixtures/real/case.txt
         | 
| 78 83 | 
             
            spec/fixtures/real/class_with_def.txt
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -72,7 +72,8 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p| | |
| 72 72 |  | 
| 73 73 | 
             
              # == Optional
         | 
| 74 74 | 
             
              p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
         | 
| 75 | 
            -
              p.extra_deps = [ ['hoe', '>= 1.2.1'], ['webgen', '>= 0.4.4'], ['activesupport', '>=1.4.2'] | 
| 75 | 
            +
              p.extra_deps = [ ['hoe', '>= 1.2.1'], ['webgen', '>= 0.4.4'], ['activesupport', '>= 1.4.2'],
         | 
| 76 | 
            +
              ['rake', '>= 0.7.3'], ['rspec', '>= 1.0.5'], ['rcov', '>= 0.8.0'], ['coderay', '>= 0.7.4']]     # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
         | 
| 76 77 | 
             
              #p.spec_extras = {}    # A hash of extra values to set in the gemspec.
         | 
| 77 78 | 
             
            end
         | 
| 78 79 |  | 
    
        data/lib/core/engine_base.rb
    CHANGED
    
    | @@ -8,11 +8,11 @@ require 'application_helper' | |
| 8 8 | 
             
            module Lazibi
         | 
| 9 9 | 
             
              class EngineBase
         | 
| 10 10 | 
             
                include Helper::ApplicationHelper
         | 
| 11 | 
            -
             | 
| 11 | 
            +
             | 
| 12 12 | 
             
                attr :up_path
         | 
| 13 13 | 
             
                attr :down_path
         | 
| 14 14 | 
             
                attr :filters
         | 
| 15 | 
            -
             | 
| 15 | 
            +
             | 
| 16 16 | 
             
                def initialize
         | 
| 17 17 | 
             
                  @filters = []
         | 
| 18 18 | 
             
                  @up_path = []
         | 
| @@ -25,16 +25,16 @@ module Lazibi | |
| 25 25 | 
             
                    @filters << fn.scan(/(.*)[.]/).to_s.to_sym
         | 
| 26 26 | 
             
                  end
         | 
| 27 27 | 
             
                end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 28 | 
            +
             | 
| 29 | 
            +
             | 
| 30 30 | 
             
                def go_up(*paths)
         | 
| 31 31 | 
             
                  @up_path += Array(paths)
         | 
| 32 32 | 
             
                end
         | 
| 33 | 
            -
             | 
| 33 | 
            +
             | 
| 34 34 | 
             
                def go_down(*paths)
         | 
| 35 35 | 
             
                  @down_path += Array(paths)
         | 
| 36 36 | 
             
                end
         | 
| 37 | 
            -
             | 
| 37 | 
            +
             | 
| 38 38 | 
             
                def up(source)
         | 
| 39 39 | 
             
                  return source if source.blank?
         | 
| 40 40 | 
             
                  transcript = source
         | 
| @@ -48,17 +48,17 @@ module Lazibi | |
| 48 48 | 
             
                      break
         | 
| 49 49 | 
             
                    end
         | 
| 50 50 | 
             
                  end
         | 
| 51 | 
            -
             | 
| 51 | 
            +
             | 
| 52 52 | 
             
                  valid ? transcript : skip_notice + "\n" + source
         | 
| 53 53 | 
             
                end
         | 
| 54 | 
            -
             | 
| 54 | 
            +
             | 
| 55 55 | 
             
                def down(source)
         | 
| 56 56 | 
             
                  return source if source.blank?
         | 
| 57 57 | 
             
                  transcript = source
         | 
| 58 58 | 
             
                  if transcript.split("\n").first == skip_notice
         | 
| 59 59 | 
             
                    return source.split("\n")[1..-1].join("\n")
         | 
| 60 60 | 
             
                  end
         | 
| 61 | 
            -
             | 
| 61 | 
            +
             | 
| 62 62 | 
             
                  @down_path.each do |step|
         | 
| 63 63 | 
             
                    class_name = step.to_s.camelize
         | 
| 64 64 | 
             
                    filter = Filter.const_get(class_name).new
         | 
| @@ -66,7 +66,7 @@ module Lazibi | |
| 66 66 | 
             
                  end
         | 
| 67 67 | 
             
                  transcript
         | 
| 68 68 | 
             
                end
         | 
| 69 | 
            -
             | 
| 69 | 
            +
             | 
| 70 70 | 
             
                def to_s
         | 
| 71 71 | 
             
                  'up_path: ' + @up_path.to_s + "\n" + 'down_path: ' + @down_path.to_s
         | 
| 72 72 | 
             
                end
         | 
    
        data/lib/filter/filter_base.rb
    CHANGED
    
    
| @@ -3,7 +3,7 @@ require 'filter_base' | |
| 3 3 | 
             
            module Lazibi
         | 
| 4 4 | 
             
              module Filter
         | 
| 5 5 | 
             
                class OptionalEnd < FilterBase
         | 
| 6 | 
            -
             | 
| 6 | 
            +
             | 
| 7 7 | 
             
                  def up( source )
         | 
| 8 8 | 
             
                    rb = source
         | 
| 9 9 | 
             
                    py = []
         | 
| @@ -47,7 +47,7 @@ module Lazibi | |
| 47 47 | 
             
                    return lines[1..-1].join("\n") if first_line == '#skip_parse'
         | 
| 48 48 | 
             
                    insert_end content
         | 
| 49 49 | 
             
                  end
         | 
| 50 | 
            -
             | 
| 50 | 
            +
             | 
| 51 51 | 
             
                  def insert_end( content )
         | 
| 52 52 | 
             
                    @lines = content.split("\n")
         | 
| 53 53 | 
             
                    progress = 0
         | 
    
        data/lib/helper/filter_helper.rb
    CHANGED
    
    | @@ -24,7 +24,8 @@ module Lazibi | |
| 24 24 | 
             
                      /\bcase\b/,
         | 
| 25 25 | 
             
                      /^class\b/,
         | 
| 26 26 | 
             
                      /^def\b/,
         | 
| 27 | 
            -
                      /\ | 
| 27 | 
            +
                      /\sdo\b/,
         | 
| 28 | 
            +
                      /^do\b/
         | 
| 28 29 | 
             
                    ]
         | 
| 29 30 | 
             
                  end
         | 
| 30 31 |  | 
| @@ -107,12 +108,12 @@ module Lazibi | |
| 107 108 |  | 
| 108 109 | 
             
                    tline
         | 
| 109 110 | 
             
                  end
         | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 111 | 
            +
             | 
| 112 | 
            +
             | 
| 112 113 | 
             
                  def clean_block(line)
         | 
| 113 114 | 
             
                    line.gsub /do\b.*?;\s*end/, ''
         | 
| 114 115 | 
             
                  end
         | 
| 115 | 
            -
             | 
| 116 | 
            +
             | 
| 116 117 | 
             
                  def split_end( source )
         | 
| 117 118 | 
             
                    lines = source.split("\n")
         | 
| 118 119 | 
             
                    new_lines = []
         | 
    
        data/lib/helper/task_helper.rb
    CHANGED
    
    | @@ -42,21 +42,21 @@ module Lazibi | |
| 42 42 | 
             
                        end
         | 
| 43 43 | 
             
                      end
         | 
| 44 44 | 
             
                    end
         | 
| 45 | 
            -
             | 
| 45 | 
            +
             | 
| 46 46 | 
             
                    sort_filter path_filters
         | 
| 47 47 | 
             
                  end
         | 
| 48 | 
            -
             | 
| 48 | 
            +
             | 
| 49 49 | 
             
                  def sort_filter( filters )
         | 
| 50 50 | 
             
                    order = @config[:filter_order] if @config
         | 
| 51 51 | 
             
                    order = [:syntax_guard, :beautify, :optional_end, :optional_do] unless order
         | 
| 52 52 | 
             
                    filters.sort{ |a,b| order.index(a) <=> order.index(b) }
         | 
| 53 53 | 
             
                  end
         | 
| 54 | 
            -
             | 
| 54 | 
            +
             | 
| 55 55 | 
             
                  def original_path(path)
         | 
| 56 56 | 
             
                    offset = 'meta'.size + 1
         | 
| 57 57 | 
             
                    path[offset..-1]
         | 
| 58 58 | 
             
                  end
         | 
| 59 | 
            -
             | 
| 59 | 
            +
             | 
| 60 60 | 
             
                  def sep_line
         | 
| 61 61 | 
             
                    puts '-' * 40
         | 
| 62 62 | 
             
                  end
         | 
    
        data/lib/lazibi.rb
    CHANGED
    
    
    
        data/lib/lazibi/version.rb
    CHANGED
    
    
    
        data/lib/task.rb
    CHANGED
    
    | @@ -9,7 +9,7 @@ require 'yaml' | |
| 9 9 | 
             
            module Lazibi
         | 
| 10 10 | 
             
              module Task
         | 
| 11 11 | 
             
                include Helper::TaskHelper
         | 
| 12 | 
            -
             | 
| 12 | 
            +
             | 
| 13 13 | 
             
                def load_config
         | 
| 14 14 | 
             
                  @config = {}
         | 
| 15 15 | 
             
                  default = {:exclude => ['^vendor'], :filters => {:optional_do => ['^spec'], :optional_end => ['']}}
         | 
| @@ -21,7 +21,7 @@ module Lazibi | |
| 21 21 | 
             
                    FileUtils.cp template_path, config_path
         | 
| 22 22 | 
             
                    puts 'created real/config/lazibi_config.rb'
         | 
| 23 23 | 
             
                  end
         | 
| 24 | 
            -
             | 
| 24 | 
            +
             | 
| 25 25 | 
             
                  puts 'loading lazibi_config.rb'
         | 
| 26 26 | 
             
                  sep_line
         | 
| 27 27 | 
             
                  require config_path
         | 
| @@ -38,7 +38,7 @@ module Lazibi | |
| 38 38 | 
             
                  real_dir = 'real'
         | 
| 39 39 | 
             
                  if File.directory? real_dir
         | 
| 40 40 | 
             
                    backup_dir = '.backup'
         | 
| 41 | 
            -
             | 
| 41 | 
            +
             | 
| 42 42 | 
             
                    # backup is disabled for now, not useful :/
         | 
| 43 43 | 
             
                    unless File.exists? backup_dir || true
         | 
| 44 44 | 
             
                      puts "backup #{real_dir} to #{backup_dir}"
         | 
| @@ -6,7 +6,7 @@ describe 'DefaultEngine' do | |
| 6 6 | 
             
              before(:each) do
         | 
| 7 7 | 
             
                @e = DefaultEngine.new
         | 
| 8 8 | 
             
              end
         | 
| 9 | 
            -
             | 
| 9 | 
            +
             | 
| 10 10 | 
             
              it "should stack filters" do
         | 
| 11 11 | 
             
                rb = "  def\n  it do\n    puts\n  end\nend"
         | 
| 12 12 | 
             
                meta ="def\n  it\n    puts"
         | 
| @@ -14,12 +14,12 @@ describe 'DefaultEngine' do | |
| 14 14 | 
             
                @e.up(rb).should == meta
         | 
| 15 15 | 
             
                @e.down(meta).should == rb_clean
         | 
| 16 16 | 
             
              end
         | 
| 17 | 
            -
             | 
| 17 | 
            +
             | 
| 18 18 | 
             
              it 'should skip' do
         | 
| 19 19 | 
             
                rb = '<<-HERE abc HERE'
         | 
| 20 20 | 
             
                @e.up(rb).should =~ /^#/
         | 
| 21 21 | 
             
              end
         | 
| 22 | 
            -
             | 
| 22 | 
            +
             | 
| 23 23 | 
             
              it 'should preserved skipped rb' do
         | 
| 24 24 | 
             
                rb = '<<-HERE abc HERE'
         | 
| 25 25 | 
             
                meta = @e.up(rb)
         | 
| @@ -5,12 +5,12 @@ describe 'EngineBase' do | |
| 5 5 | 
             
              before(:each) do
         | 
| 6 6 | 
             
                @e = EngineBase.new
         | 
| 7 7 | 
             
              end
         | 
| 8 | 
            -
             | 
| 8 | 
            +
             | 
| 9 9 | 
             
              it "should be able to go_up" do
         | 
| 10 10 | 
             
                @e.go_up(:beautify)
         | 
| 11 11 | 
             
                @e.up('  def;end').should == "def;end\n"
         | 
| 12 12 | 
             
              end
         | 
| 13 | 
            -
             | 
| 13 | 
            +
             | 
| 14 14 | 
             
              it "should stack filters" do
         | 
| 15 15 | 
             
                rb = "  def\n  it do\n    puts\n  end\nend"
         | 
| 16 16 | 
             
                meta ="def\n  it\n    puts"
         | 
| @@ -5,7 +5,7 @@ module Lazibi | |
| 5 5 | 
             
                describe 'BeautifyFilter' do
         | 
| 6 6 | 
             
                  before(:all) do
         | 
| 7 7 | 
             
                    @f = Beautify.new
         | 
| 8 | 
            -
             | 
| 8 | 
            +
             | 
| 9 9 | 
             
                    # load fixtures
         | 
| 10 10 | 
             
                    @p_rbs = {}
         | 
| 11 11 | 
             
                    @p_metas = {}
         | 
| @@ -39,21 +39,21 @@ module Lazibi | |
| 39 39 | 
             
                      @metas[fn.scan(/(.*)[.]/).to_s.to_sym] = File.read(meta_dir + "/#{fn}")
         | 
| 40 40 | 
             
                    end
         | 
| 41 41 | 
             
                  end
         | 
| 42 | 
            -
             | 
| 42 | 
            +
             | 
| 43 43 | 
             
                  it "should beautify public" do
         | 
| 44 44 | 
             
                    @p_metas.keys.each do |k|
         | 
| 45 45 | 
             
                      @f.up(@p_rbs[k]).should == @p_metas[k]
         | 
| 46 46 | 
             
                    end
         | 
| 47 47 | 
             
                  end
         | 
| 48 | 
            -
             | 
| 48 | 
            +
             | 
| 49 49 | 
             
                  it 'should clean str.gsub(/([^ \/a-zA-Z0-9_.-])/n)' do
         | 
| 50 50 | 
             
                    @f.clean_line('str.gsub(/([^ \/a-zA-Z0-9_.-])/n)').should == 'str.gsub(//n)'
         | 
| 51 51 | 
             
                  end
         | 
| 52 | 
            -
             | 
| 52 | 
            +
             | 
| 53 53 | 
             
                  it 'should clean %r{\A#{Regexp.escape(expanded_root)}(/|\\)}' do
         | 
| 54 54 | 
             
                    @f.clean_line('%r{\A#{Regexp.escape(expanded_root)}(/|\\)}').should == "''"
         | 
| 55 55 | 
             
                  end
         | 
| 56 | 
            -
             | 
| 56 | 
            +
             | 
| 57 57 | 
             
                  it 'should beautify' do
         | 
| 58 58 | 
             
                    @metas.keys.each do |k|
         | 
| 59 59 | 
             
                      @f.up(@rbs[k]).should == @metas[k]
         | 
| @@ -7,7 +7,7 @@ module Lazibi | |
| 7 7 | 
             
                    @f = OptionalDo.new
         | 
| 8 8 | 
             
                    @beautify = Beautify.new
         | 
| 9 9 | 
             
                    @optional_end = OptionalEnd.new
         | 
| 10 | 
            -
             | 
| 10 | 
            +
             | 
| 11 11 | 
             
                    # load fixtures
         | 
| 12 12 | 
             
                    @rbs = {}
         | 
| 13 13 | 
             
                    @metas = {}
         | 
| @@ -30,22 +30,22 @@ module Lazibi | |
| 30 30 | 
             
                    @f.up('it do').should == 'it'
         | 
| 31 31 | 
             
                    @f.down("it\n  abc").should == "it do\n  abc"
         | 
| 32 32 | 
             
                  end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 33 | 
            +
             | 
| 34 | 
            +
             | 
| 35 35 | 
             
                  it 'should integrate with beautify and optional_end' do
         | 
| 36 36 | 
             
                    list = [:classical, :lambda, :brackets_block, :describe, :do_block, :square_brackets]
         | 
| 37 37 | 
             
                    list.each do |name|
         | 
| 38 38 | 
             
                      assert_integrate name
         | 
| 39 39 | 
             
                    end
         | 
| 40 40 | 
             
                  end
         | 
| 41 | 
            -
             | 
| 41 | 
            +
             | 
| 42 42 | 
             
                  def assert_integrate(name, debug = false)
         | 
| 43 43 | 
             
                    code = @rbs[name]
         | 
| 44 44 | 
             
                    code = @beautify.up(code)
         | 
| 45 45 | 
             
                    code = @optional_end.up(code)
         | 
| 46 46 | 
             
                    code = @f.up(code)
         | 
| 47 47 | 
             
                    code.should == @metas[name]
         | 
| 48 | 
            -
             | 
| 48 | 
            +
             | 
| 49 49 | 
             
                    code = @metas[name]
         | 
| 50 50 | 
             
                    code = @f.down(code)
         | 
| 51 51 | 
             
                    code = @optional_end.down(code)
         | 
| @@ -5,25 +5,45 @@ module Lazibi | |
| 5 5 | 
             
                describe 'OptionalEndFilter' do
         | 
| 6 6 | 
             
                  before(:all) do
         | 
| 7 7 | 
             
                    @f = OptionalEnd.new
         | 
| 8 | 
            -
             | 
| 8 | 
            +
             | 
| 9 9 | 
             
                    # load fixtures
         | 
| 10 | 
            -
                    @ | 
| 11 | 
            -
                    @ | 
| 10 | 
            +
                    @p_rbs = {}
         | 
| 11 | 
            +
                    @p_metas = {}
         | 
| 12 12 |  | 
| 13 13 |  | 
| 14 14 | 
             
                    rb_dir = FIXTURE_DIR + '/real'
         | 
| 15 15 | 
             
                    Dir.open(rb_dir).each do |fn|
         | 
| 16 16 | 
             
                      next unless fn =~ /[.]txt$/
         | 
| 17 | 
            -
                      @ | 
| 17 | 
            +
                      @p_rbs[fn.scan(/(.*)[.]/).to_s.to_sym] = File.read(rb_dir + "/#{fn}")
         | 
| 18 18 | 
             
                    end
         | 
| 19 19 |  | 
| 20 20 | 
             
                    meta_dir = FIXTURE_DIR + '/meta'
         | 
| 21 | 
            +
                    Dir.open(meta_dir).each do |fn|
         | 
| 22 | 
            +
                      next unless fn =~ /[.]txt$/
         | 
| 23 | 
            +
                      @p_metas[fn.scan(/(.*)[.]/).to_s.to_sym] = File.read(meta_dir + "/#{fn}")
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                      @beautify = Beautify.new
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                      # load fixtures
         | 
| 28 | 
            +
                      @rbs = {}
         | 
| 29 | 
            +
                      @metas = {}
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
             | 
| 33 | 
            +
                    rb_dir = FIXTURE_DIR + '/optional_end/rbs'
         | 
| 34 | 
            +
                    Dir.open(rb_dir).each do |fn|
         | 
| 35 | 
            +
                      next unless fn =~ /[.]txt$/
         | 
| 36 | 
            +
                      @rbs[fn.scan(/(.*)[.]/).to_s.to_sym] = File.read(rb_dir + "/#{fn}")
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    meta_dir = FIXTURE_DIR + '/optional_end/metas'
         | 
| 21 40 | 
             
                    Dir.open(meta_dir).each do |fn|
         | 
| 22 41 | 
             
                      next unless fn =~ /[.]txt$/
         | 
| 23 42 | 
             
                      @metas[fn.scan(/(.*)[.]/).to_s.to_sym] = File.read(meta_dir + "/#{fn}")
         | 
| 24 43 | 
             
                    end
         | 
| 25 44 | 
             
                  end
         | 
| 26 | 
            -
             | 
| 45 | 
            +
             | 
| 46 | 
            +
             | 
| 27 47 | 
             
                  it "should find end" do
         | 
| 28 48 | 
             
                    assert_find :basic_class, 0, 0
         | 
| 29 49 | 
             
                    assert_find :class_with_def, 0, 1
         | 
| @@ -37,34 +57,52 @@ module Lazibi | |
| 37 57 | 
             
                  end
         | 
| 38 58 |  | 
| 39 59 | 
             
                  it "should preserve" do
         | 
| 40 | 
            -
                    @ | 
| 60 | 
            +
                    @p_metas.keys.reject{|k| ['partial_method', 'inline_end', 'optional_do',
         | 
| 41 61 | 
             
                    'eval_code', 'here_doc', 'single_method', 'comment_after_end'].include? k.to_s }.each do |k|
         | 
| 42 | 
            -
                       | 
| 62 | 
            +
                      assert_preserve_p k
         | 
| 43 63 | 
             
                    end
         | 
| 44 64 | 
             
                  end
         | 
| 45 65 |  | 
| 46 | 
            -
             | 
| 66 | 
            +
             | 
| 47 67 | 
             
                  it "should convert to rb" do
         | 
| 48 | 
            -
                     | 
| 49 | 
            -
                     | 
| 50 | 
            -
                     | 
| 68 | 
            +
                    assert_to_rb_p :partial_method
         | 
| 69 | 
            +
                    assert_to_rb_p :eval_code
         | 
| 70 | 
            +
                    assert_to_rb_p :comment_after_end, :comment_after_end_expected
         | 
| 51 71 | 
             
                  end
         | 
| 52 72 |  | 
| 53 73 | 
             
                  it "should convert to meta" do
         | 
| 54 | 
            -
                     | 
| 55 | 
            -
                     | 
| 74 | 
            +
                    assert_to_meta_p :inline_end
         | 
| 75 | 
            +
                    assert_to_meta_p :comment_after_end
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                  it "should ignore :do" do
         | 
| 79 | 
            +
                    assert_preserve( :space_sep_do )
         | 
| 56 80 | 
             
                  end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                      
         | 
| 81 | 
            +
             | 
| 59 82 | 
             
                  def assert_find( name, indent, end_i, range = nil )
         | 
| 60 83 | 
             
                    unless range
         | 
| 61 | 
            -
                      @f.find_end(@ | 
| 84 | 
            +
                      @f.find_end(@p_metas[name].split("\n"), indent).should == end_i
         | 
| 62 85 | 
             
                    else
         | 
| 63 | 
            -
                      @f.find_end(@ | 
| 86 | 
            +
                      @f.find_end(@p_metas[name].split("\n")[range], indent).should == end_i
         | 
| 64 87 | 
             
                    end
         | 
| 65 88 | 
             
                  end
         | 
| 66 89 |  | 
| 67 | 
            -
             | 
| 90 | 
            +
             | 
| 91 | 
            +
                  def assert_to_rb_p( name, name_2 = nil )
         | 
| 92 | 
            +
                    name_2 = name unless name_2
         | 
| 93 | 
            +
                    @f.down( @p_metas[name]).should == @p_rbs[name_2]
         | 
| 94 | 
            +
                  end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                  def assert_to_meta_p( name, name_2 = nil )
         | 
| 97 | 
            +
                    name_2 = name unless name_2
         | 
| 98 | 
            +
                    @f.up( @p_rbs[name]).should == @p_metas[name_2]
         | 
| 99 | 
            +
                  end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                  def assert_preserve_p( name )
         | 
| 102 | 
            +
                    assert_to_rb_p(name)
         | 
| 103 | 
            +
                    assert_to_meta_p(name)
         | 
| 104 | 
            +
                  end
         | 
| 105 | 
            +
             | 
| 68 106 | 
             
                  def assert_to_rb( name, name_2 = nil )
         | 
| 69 107 | 
             
                    name_2 = name unless name_2
         | 
| 70 108 | 
             
                    @f.down( @metas[name]).should == @rbs[name_2]
         | 
| @@ -5,7 +5,7 @@ include Filter | |
| 5 5 |  | 
| 6 6 | 
             
            module Lazibi
         | 
| 7 7 | 
             
              module Spec
         | 
| 8 | 
            -
             | 
| 8 | 
            +
             | 
| 9 9 | 
             
                describe 'FilterHelper' do
         | 
| 10 10 | 
             
                  include Helper::FilterHelper
         | 
| 11 11 | 
             
                  it 'should detect start anchor' do
         | 
| @@ -16,17 +16,17 @@ module Lazibi | |
| 16 16 | 
             
                    start_anchor?( '"abc do  |"').should == false
         | 
| 17 17 | 
             
                    start_anchor?( 'lambda').should == false
         | 
| 18 18 | 
             
                  end
         | 
| 19 | 
            -
             | 
| 19 | 
            +
             | 
| 20 20 | 
             
                  it 'should detect end anchor' do
         | 
| 21 21 | 
             
                    end_anchor?( 'lambda' ).should == false
         | 
| 22 22 | 
             
                  end
         | 
| 23 | 
            -
             | 
| 23 | 
            +
             | 
| 24 24 | 
             
                  it 'should detect middle anchor' do
         | 
| 25 25 | 
             
                    middle_anchor?( '' ).should == false
         | 
| 26 26 | 
             
                    middle_anchor?( 'rescue' ).should == true
         | 
| 27 27 | 
             
                    middle_anchor?( 'lambda').should == false
         | 
| 28 28 | 
             
                  end
         | 
| 29 | 
            -
             | 
| 29 | 
            +
             | 
| 30 30 | 
             
                  it 'should detect comment at end' do
         | 
| 31 31 | 
             
                    comment_at_end('  dab #abcd').should_not be_nil
         | 
| 32 32 | 
             
                  end
         | 
| @@ -11,8 +11,8 @@ module Lazibi | |
| 11 11 | 
             
                    convert_path( 'real/abc.rb' ).should == 'meta/abc.py.rb'
         | 
| 12 12 | 
             
                    convert_path( 'meta/lib/abc.py.rb' ).should == 'real/lib/abc.rb'
         | 
| 13 13 | 
             
                  end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 14 | 
            +
             | 
| 15 | 
            +
             | 
| 16 16 | 
             
                  it 'should soft filters' do
         | 
| 17 17 | 
             
                    sort_filter([:optional_end, :optional_do, :beautify]).should == [:beautify, :optional_end, :optional_do]
         | 
| 18 18 | 
             
                  end
         | 
    
        data/spec/lazibi_spec.rb
    CHANGED
    
    | @@ -2,13 +2,13 @@ require File.dirname(__FILE__) + '/spec_helper' | |
| 2 2 |  | 
| 3 3 | 
             
            module Lazibi
         | 
| 4 4 | 
             
              module Spec
         | 
| 5 | 
            -
             | 
| 5 | 
            +
             | 
| 6 6 | 
             
                describe 'Lazibi' do
         | 
| 7 7 | 
             
                  before(:all) do
         | 
| 8 8 | 
             
                    @r = Lazibi::Runner.new
         | 
| 9 9 | 
             
                    @r.load_config
         | 
| 10 10 | 
             
                  end
         | 
| 11 | 
            -
             | 
| 11 | 
            +
             | 
| 12 12 | 
             
                  it 'should load default config' do
         | 
| 13 13 | 
             
                    @r.config[:exclude].should_not be_nil
         | 
| 14 14 | 
             
                  end
         | 
| @@ -18,5 +18,4 @@ module Lazibi | |
| 18 18 | 
             
                  end
         | 
| 19 19 | 
             
                end
         | 
| 20 20 | 
             
              end
         | 
| 21 | 
            -
            end
         | 
| 22 | 
            -
                    
         | 
| 21 | 
            +
            end
         | 
    
        data/webgen/src/faq.page
    CHANGED
    
    | @@ -19,9 +19,7 @@ create .py.rb files in corresponding directories inside 'meta', .rb files will b | |
| 19 19 |  | 
| 20 20 | 
             
            h1. Exclude certain directories
         | 
| 21 21 |  | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
            Edit lazibi_config.rb in project/real/config/
         | 
| 22 | 
            +
            Stop Lazibi process, edit lazibi_config.rb in project/real/config/, start Lazibi. For example:
         | 
| 25 23 |  | 
| 26 24 | 
             
            <pre>
         | 
| 27 25 | 
             
            def exclude
         | 
| @@ -31,7 +29,7 @@ end | |
| 31 29 |  | 
| 32 30 | 
             
            h1. RSpec taste
         | 
| 33 31 |  | 
| 34 | 
            -
             | 
| 32 | 
            +
            Edit lazibi_config.rb in project/real/config/. For example:
         | 
| 35 33 |  | 
| 36 34 | 
             
            <pre>
         | 
| 37 35 | 
             
            def filters
         | 
    
        metadata
    CHANGED
    
    | @@ -3,8 +3,8 @@ rubygems_version: 0.9.4 | |
| 3 3 | 
             
            specification_version: 1
         | 
| 4 4 | 
             
            name: lazibi
         | 
| 5 5 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            -
              version: 0.1. | 
| 7 | 
            -
            date: 2007- | 
| 6 | 
            +
              version: 0.1.15
         | 
| 7 | 
            +
            date: 2007-07-08 00:00:00 +08:00
         | 
| 8 8 | 
             
            summary: Python like indenting for Ruby
         | 
| 9 9 | 
             
            require_paths: 
         | 
| 10 10 | 
             
            - lib
         | 
| @@ -36,6 +36,7 @@ files: | |
| 36 36 | 
             
            - README.txt
         | 
| 37 37 | 
             
            - Rakefile
         | 
| 38 38 | 
             
            - bin/lazibi
         | 
| 39 | 
            +
            - config/lazibi_config.rb
         | 
| 39 40 | 
             
            - config/lazibi_config_template.rb
         | 
| 40 41 | 
             
            - lib/core/beautify_engine.rb
         | 
| 41 42 | 
             
            - lib/core/default_engine.rb
         | 
| @@ -62,7 +63,9 @@ files: | |
| 62 63 | 
             
            - spec/filter/optional_do_filter_spec.rb
         | 
| 63 64 | 
             
            - spec/filter/optional_end_filter_spec.rb
         | 
| 64 65 | 
             
            - spec/filter/syntax_guard_filter_spec.rb
         | 
| 66 | 
            +
            - spec/fixtures/beautify/metas/space_sep_do.txt
         | 
| 65 67 | 
             
            - spec/fixtures/beautify/metas/square_brackets.txt
         | 
| 68 | 
            +
            - spec/fixtures/beautify/rbs/space_sep_do.txt
         | 
| 66 69 | 
             
            - spec/fixtures/beautify/rbs/square_brackets.txt
         | 
| 67 70 | 
             
            - spec/fixtures/clean/comment_break.txt
         | 
| 68 71 | 
             
            - spec/fixtures/clean/complex_string.txt
         | 
| @@ -104,6 +107,8 @@ files: | |
| 104 107 | 
             
            - spec/fixtures/optional_do/rbs/do_block.txt
         | 
| 105 108 | 
             
            - spec/fixtures/optional_do/rbs/lambda.txt
         | 
| 106 109 | 
             
            - spec/fixtures/optional_do/rbs/square_brackets.txt
         | 
| 110 | 
            +
            - spec/fixtures/optional_end/metas/space_sep_do.txt
         | 
| 111 | 
            +
            - spec/fixtures/optional_end/rbs/space_sep_do.txt
         | 
| 107 112 | 
             
            - spec/fixtures/real/basic_class.txt
         | 
| 108 113 | 
             
            - spec/fixtures/real/case.txt
         | 
| 109 114 | 
             
            - spec/fixtures/real/class_with_def.txt
         | 
| @@ -166,7 +171,9 @@ extra_rdoc_files: | |
| 166 171 | 
             
            - License.txt
         | 
| 167 172 | 
             
            - Manifest.txt
         | 
| 168 173 | 
             
            - README.txt
         | 
| 174 | 
            +
            - spec/fixtures/beautify/metas/space_sep_do.txt
         | 
| 169 175 | 
             
            - spec/fixtures/beautify/metas/square_brackets.txt
         | 
| 176 | 
            +
            - spec/fixtures/beautify/rbs/space_sep_do.txt
         | 
| 170 177 | 
             
            - spec/fixtures/beautify/rbs/square_brackets.txt
         | 
| 171 178 | 
             
            - spec/fixtures/clean/comment_break.txt
         | 
| 172 179 | 
             
            - spec/fixtures/clean/complex_string.txt
         | 
| @@ -208,6 +215,8 @@ extra_rdoc_files: | |
| 208 215 | 
             
            - spec/fixtures/optional_do/rbs/do_block.txt
         | 
| 209 216 | 
             
            - spec/fixtures/optional_do/rbs/lambda.txt
         | 
| 210 217 | 
             
            - spec/fixtures/optional_do/rbs/square_brackets.txt
         | 
| 218 | 
            +
            - spec/fixtures/optional_end/metas/space_sep_do.txt
         | 
| 219 | 
            +
            - spec/fixtures/optional_end/rbs/space_sep_do.txt
         | 
| 211 220 | 
             
            - spec/fixtures/real/basic_class.txt
         | 
| 212 221 | 
             
            - spec/fixtures/real/case.txt
         | 
| 213 222 | 
             
            - spec/fixtures/real/class_with_def.txt
         | 
| @@ -265,3 +274,39 @@ dependencies: | |
| 265 274 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 266 275 | 
             
                    version: 1.4.2
         | 
| 267 276 | 
             
                version: 
         | 
| 277 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 278 | 
            +
              name: rake
         | 
| 279 | 
            +
              version_requirement: 
         | 
| 280 | 
            +
              version_requirements: !ruby/object:Gem::Version::Requirement 
         | 
| 281 | 
            +
                requirements: 
         | 
| 282 | 
            +
                - - ">="
         | 
| 283 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 284 | 
            +
                    version: 0.7.3
         | 
| 285 | 
            +
                version: 
         | 
| 286 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 287 | 
            +
              name: rspec
         | 
| 288 | 
            +
              version_requirement: 
         | 
| 289 | 
            +
              version_requirements: !ruby/object:Gem::Version::Requirement 
         | 
| 290 | 
            +
                requirements: 
         | 
| 291 | 
            +
                - - ">="
         | 
| 292 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 293 | 
            +
                    version: 1.0.5
         | 
| 294 | 
            +
                version: 
         | 
| 295 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 296 | 
            +
              name: rcov
         | 
| 297 | 
            +
              version_requirement: 
         | 
| 298 | 
            +
              version_requirements: !ruby/object:Gem::Version::Requirement 
         | 
| 299 | 
            +
                requirements: 
         | 
| 300 | 
            +
                - - ">="
         | 
| 301 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 302 | 
            +
                    version: 0.8.0
         | 
| 303 | 
            +
                version: 
         | 
| 304 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 305 | 
            +
              name: coderay
         | 
| 306 | 
            +
              version_requirement: 
         | 
| 307 | 
            +
              version_requirements: !ruby/object:Gem::Version::Requirement 
         | 
| 308 | 
            +
                requirements: 
         | 
| 309 | 
            +
                - - ">="
         | 
| 310 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 311 | 
            +
                    version: 0.7.4
         | 
| 312 | 
            +
                version: 
         |