[DRE-commits] [ruby-beautify] 03/04: Patch for newline issue and depreciation fixes.

Tomasz Nitecki tnnn-guest at moszumanska.debian.org
Tue Oct 21 08:14:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

tnnn-guest pushed a commit to branch master
in repository ruby-beautify.

commit 7b3e9b5cd5c0d6d6bd90673a732caa262e77a60c
Author: Tomasz Nitecki <tnnn at tnnn.pl>
Date:   Tue Oct 21 10:07:57 2014 +0200

    Patch for newline issue and depreciation fixes.
---
 .../0010_replace_deprecated_mock_and_stub.patch    | 135 +++++++++++++++++++++
 .../0020_fix_deprecation_and_newline_issues.patch  |  24 ++++
 debian/patches/series                              |   2 +
 3 files changed, 161 insertions(+)

diff --git a/debian/patches/0010_replace_deprecated_mock_and_stub.patch b/debian/patches/0010_replace_deprecated_mock_and_stub.patch
new file mode 100644
index 0000000..7b8e4da
--- /dev/null
+++ b/debian/patches/0010_replace_deprecated_mock_and_stub.patch
@@ -0,0 +1,135 @@
+Description: replace deprecated mock and stub! with double and stub
+Author: Tomasz Nitecki <tnnn at tnnn.pl>
+Last-Update: 2014-10-19
+
+--- a/spec/rbeautify/block_matcher_spec.rb
++++ b/spec/rbeautify/block_matcher_spec.rb
+@@ -68,22 +68,22 @@
+ 
+   describe '#can_nest?' do
+     before(:each) do
+-      @language = mock(RBeautify::Language)
++      @language = double(RBeautify::Language)
+     end
+ 
+     it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/).should be_can_nest(nil) }
+ 
+-    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/).should be_can_nest(mock('block_start', :parse_content? => true)) }
++    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/).should be_can_nest(double('block_start', :parse_content? => true)) }
+ 
+-    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/).should_not be_can_nest(mock('block_start', :parse_content? => false)) }
++    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/).should_not be_can_nest(double('block_start', :parse_content? => false)) }
+ 
+     it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/, :nest_except => [:bar]).should be_can_nest(nil) }
+ 
+-    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/, :nest_except => [:foo]).should be_can_nest(mock('block_start', :name => :bar, :parse_content? => true)) }
++    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/, :nest_except => [:foo]).should be_can_nest(double('block_start', :name => :bar, :parse_content? => true)) }
+ 
+-    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/, :nest_except => [:foo]).should_not be_can_nest(mock('block_start', :name => :bar, :parse_content? => false)) }
++    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/, :nest_except => [:foo]).should_not be_can_nest(double('block_start', :name => :bar, :parse_content? => false)) }
+ 
+-    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/, :nest_except => [:bar]).should_not be_can_nest(mock('block_start', :name => :bar, :parse_content? => true)) }
++    it { RBeautify::BlockMatcher.new(@language, :foo, /foo/, /bar/, :nest_except => [:bar]).should_not be_can_nest(double('block_start', :name => :bar, :parse_content? => true)) }
+   end
+ 
+ end
+--- a/spec/rbeautify/block_start_spec.rb
++++ b/spec/rbeautify/block_start_spec.rb
+@@ -43,7 +43,7 @@
+     it { RBeautify::BlockStart.new(@ruby.matcher(:standard), nil, 0, 0, 'def', ' foo') .total_indent_size.should == 2 }
+ 
+     it 'should sum with parents total indent size' do
+-      parent = mock('parent_start_block', :total_indent_size => 4)
++      parent = double('parent_start_block', :total_indent_size => 4)
+       RBeautify::BlockStart.new(@ruby.matcher(:standard), parent, 0, 0, 'def', ' foo') .total_indent_size.should == 6
+     end
+   end
+--- a/spec/rbeautify/line_spec.rb
++++ b/spec/rbeautify/line_spec.rb
+@@ -5,66 +5,66 @@
+   describe '#format' do
+ 
+     before(:each) do
+-      @language = mock(RBeautify::Language)
++      @language = double(RBeautify::Language)
+     end
+ 
+     it 'should just strip with empty stack' do
+-      RBeautify::BlockMatcher.stub!(:parse => nil)
++      RBeautify::BlockMatcher.stub(:parse => nil)
+       RBeautify::Line.new(@language, ' a = 3 ', 0).format.should == "a = 3"
+     end
+ 
+     it 'should indent with existing indent' do
+-      current_block = mock('block_start', :total_indent_size => 2, :format_content? => true, :strict_ancestor_of? => false)
++      current_block = double('block_start', :total_indent_size => 2, :format_content? => true, :strict_ancestor_of? => false)
+       RBeautify::BlockStart.stub(:first_common_ancestor => current_block)
+-      RBeautify::BlockMatcher.stub!(:parse => current_block)
++      RBeautify::BlockMatcher.stub(:parse => current_block)
+       RBeautify::Line.new(@language, ' a = 3 ', 0, current_block).format.should == '  a = 3'
+     end
+ 
+     it 'leave empty lines blank' do
+-      current_block = mock('block_start', :format_content? => true)
+-      RBeautify::BlockMatcher.stub!(:parse => current_block)
++      current_block = double('block_start', :format_content? => true)
++      RBeautify::BlockMatcher.stub(:parse => current_block)
+       RBeautify::Line.new(@language, '    ', 0, current_block).format.should == ''
+     end
+ 
+     it 'should remove indent with match to end of block' do
+-      current_block = mock('block_start', :format_content? => true, :indent_end_line? => false)
++      current_block = double('block_start', :format_content? => true, :indent_end_line? => false)
+       RBeautify::BlockStart.stub(:first_common_ancestor => nil)
+-      RBeautify::BlockMatcher.stub!(:parse => nil)
++      RBeautify::BlockMatcher.stub(:parse => nil)
+       RBeautify::Line.new(@language, '  end ', 0, current_block).format.should == 'end'
+     end
+ 
+     it 'should not remove indent with match to end of block if indent_end_line? is true' do
+-      current_block = mock('block_start', :total_indent_size => 2, :format_content? => true, :indent_end_line? => true)
+-      RBeautify::BlockMatcher.stub!(:parse => nil)
++      current_block = double('block_start', :total_indent_size => 2, :format_content? => true, :indent_end_line? => true)
++      RBeautify::BlockMatcher.stub(:parse => nil)
+       RBeautify::Line.new(@language, '  end ', 0, current_block).format.should == '  end'
+     end
+ 
+     it 'should leave indent at old stack level with match of new block' do
+-      current_block = mock('current_block_start', :total_indent_size => 2, :format_content? => true)
+-      new_block = mock('new_block_start', :format_content? => true, :strict_ancestor_of? => false)
++      current_block = double('current_block_start', :total_indent_size => 2, :format_content? => true)
++      new_block = double('new_block_start', :format_content? => true, :strict_ancestor_of? => false)
+       RBeautify::BlockStart.stub(:first_common_ancestor => current_block)
+-      RBeautify::BlockMatcher.stub!(:parse => new_block)
++      RBeautify::BlockMatcher.stub(:parse => new_block)
+       RBeautify::Line.new(@language, 'class Foo', 0, current_block).format.should == '  class Foo'
+     end
+ 
+     it 'should remove indent if a block ends and starts' do
+-      current_block = mock('current_block_start', :format_content? => true)
+-      new_block = mock('new_block_start', :format_content? => true, :strict_ancestor_of? => false)
++      current_block = double('current_block_start', :format_content? => true)
++      new_block = double('new_block_start', :format_content? => true, :strict_ancestor_of? => false)
+       RBeautify::BlockStart.stub(:first_common_ancestor => nil)
+-      RBeautify::BlockMatcher.stub!(:parse => new_block)
++      RBeautify::BlockMatcher.stub(:parse => new_block)
+       RBeautify::Line.new(@language, '   else   ', 0, current_block).format.should == 'else'
+     end
+ 
+     it 'should not change when format is false' do
+-      current_block = mock('block_start', :format_content? => false)
+-      RBeautify::BlockMatcher.stub!(:parse => current_block)
++      current_block = double('block_start', :format_content? => false)
++      RBeautify::BlockMatcher.stub(:parse => current_block)
+       RBeautify::Line.new(@language, ' some content after program has finished. ', 0, current_block).format.should ==
+         " some content after program has finished. "
+     end
+ 
+     it 'should leave indent with match to end of block (but no format)' do
+-      current_block = mock('block_start', :format_content? => false)
+-      RBeautify::BlockMatcher.stub!(:parse => nil)
++      current_block = double('block_start', :format_content? => false)
++      RBeautify::BlockMatcher.stub(:parse => nil)
+       RBeautify::Line.new(@language, '  "', 0, current_block).format.should == '  "'
+     end
+ 
diff --git a/debian/patches/0020_fix_deprecation_and_newline_issues.patch b/debian/patches/0020_fix_deprecation_and_newline_issues.patch
new file mode 100644
index 0000000..41bf4e8
--- /dev/null
+++ b/debian/patches/0020_fix_deprecation_and_newline_issues.patch
@@ -0,0 +1,24 @@
+Description: if a line already ends with newline (\n) don't append another newline (\n); replace deprecated lines with each_line
+Author: Tomasz Nitecki <tnnn at tnnn.pl>
+Last-Update: 2014-10-21
+
+--- a/lib/ruby-beautify.rb
++++ b/lib/ruby-beautify.rb
+@@ -1,4 +1,4 @@
+-require "ruby-beautify/version"
++require 'ruby-beautify/version'
+ require 'ruby-beautify/block_start'
+ require 'ruby-beautify/block_end'
+ require 'ruby-beautify/block_matcher'
+@@ -15,9 +15,9 @@
+       language = RBeautify::Language.language(language)
+     end
+ 
+-    source.lines.each_with_index do |line_content, line_number|
++    source.each_line.each_with_index do |line_content, line_number|
+       line = RBeautify::Line.new(language, line_content, line_number, block, use_tabs)
+-      dest += line.format + "\n"
++      dest += line.format + (line.format.end_with?("\n") ? "" : "\n")
+       block = line.block
+     end
+ 
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..5345a6e
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+0010_replace_deprecated_mock_and_stub.patch
+0020_fix_deprecation_and_newline_issues.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-beautify.git



More information about the Pkg-ruby-extras-commits mailing list