heredoc_unindent 1.1.0 → 1.1.1

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.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,12 @@
1
+ === 1.1.1 / 2011-01-29
2
+
3
+ * 1 bugfix
4
+
5
+ * Replaced <tt>\s</tt>, which is equivalent to <tt>[ \t\r\n\f]</tt>,
6
+ by <tt>[ \t]</tt> in regular expression
7
+ * empty lines could lead to wrong behaviour
8
+ * Added tests to prevent the just-fixed bug to ever come back
9
+
1
10
  === 1.1.0 / 2011-01-29
2
11
 
3
12
  * 3 minor enhancements
@@ -75,7 +75,7 @@ implement equivalent unindenting functionality:
75
75
 
76
76
  1. {outdent}[http://rubygems.org/gems/outdent] (formerly {unindentable}[http://rubygems.org/gems/unindentable])
77
77
  2. {unindent}[http://rubygems.org/gems/unindent]
78
- 3. {indentation}[http://rubygems.org/gems/indentation] -- this gem has a broader scope, besides String#reset_indentation
78
+ 3. {indentation}[http://rubygems.org/gems/indentation] -- this gem has a broader scope, in addition to String#reset_indentation
79
79
 
80
80
  === So why another one?
81
81
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'hoe'
6
6
  Hoe.spec 'heredoc_unindent' do
7
7
  developer('Adriano Mitre', 'adriano.mitre@gmail.com')
8
8
 
9
- self.version = '1.1.0'
9
+ self.version = '1.1.1'
10
10
 
11
11
  self.readme_file = 'README.rdoc'
12
12
  self.history_file = 'History.rdoc'
@@ -1,10 +1,13 @@
1
1
  == SUGGESTIONS
2
2
 
3
- * Benchmark heredoc_unindent against alternatives:
4
- * outdent
5
- * unindent
6
- * the code posted by Rene Saarsoo in his answer in StackOverflow.
7
- and then
8
- * if there are significant performance differences, contact the other authors
9
- and suggest unifying gems, keeping the fastest implementation
10
- * mention the results in README (table?)
3
+ * added a mechanism for "ignoring" blank lines, i.e.,
4
+ * not include the margin of blank lines in the minimum calculation
5
+ * let them untouched (i.e., unprocessed)
6
+ * possible implementation:
7
+ re = Regexp.new '^\s{' + n.to_s + '}(\S+)$'
8
+ s.gsub(re,'\1')
9
+ instead of
10
+ re = Regexp.new '^\s{' + n.to_s + '}'
11
+ s.gsub(re, '')
12
+ * re-benchmark to make sure it does not hurt performance and performance
13
+ figures in README are still valid
@@ -26,7 +26,7 @@ module CoreExt
26
26
  def unindent_base_new(in_place, warn_first_not_min)
27
27
  m_first = nil
28
28
  m_min = nil
29
- self.scan(/^\s*/) do |m|
29
+ self.scan(/^[ \t]*/) do |m|
30
30
  ms = m.size
31
31
  m_first ||= ms
32
32
  m_min = ms if !m_min || ms < m_min
@@ -43,7 +43,7 @@ module CoreExt
43
43
  # about 10% faster in ree, 20% in ruby-1.8.7 (old vs new)
44
44
  #
45
45
  def unindent_base_old(in_place, warn_first_not_min)
46
- margins = self.scan(/^\s*/).map(&:size)
46
+ margins = self.scan(/^[ \t]*/).map(&:size)
47
47
  margins_min = margins.min
48
48
  if margins.first != margins_min && warn_first_not_min
49
49
  puts "warning: margin of the first line differs from minimum margin"
@@ -41,6 +41,21 @@ EOS
41
41
  The third line
42
42
  EOS
43
43
 
44
+ pretty = <<EOS
45
+ The first line
46
+
47
+ The third line
48
+ EOS
49
+ return ugly, pretty
50
+ end
51
+
52
+ def prep_sing4
53
+ ugly = <<-EOS
54
+ The first line
55
+
56
+ The third line
57
+ EOS
58
+
44
59
  pretty = <<EOS
45
60
  The first line
46
61
 
@@ -64,8 +79,10 @@ EOS
64
79
  end
65
80
 
66
81
  def test_unindent
67
- perform_tests(*prep_sing1)
68
- perform_tests(*prep_sing2)
82
+ 1.upto(4) do |n|
83
+ m = method "prep_sing#{n}"
84
+ perform_tests(*m.call)
85
+ end
69
86
  perform_tests(*prep_mult)
70
87
  end
71
88
 
@@ -74,11 +91,11 @@ EOS
74
91
  assert_equal pretty, ugly.unindent(false)
75
92
  assert_equal pretty, ugly.heredoc_unindent(false)
76
93
  assert_equal ugly_bak, ugly, '#unindent should have no side-effects'
77
- assert_equal pretty, ugly.heredoc_unindent!(false)
94
+ assert_equal pretty, ugly.heredoc_unindent!(false) unless pretty == ugly
78
95
  assert_equal pretty, ugly
79
96
  assert_equal nil, ugly.heredoc_unindent!(false)
80
97
  ugly = ugly_bak.dup
81
- assert_equal pretty, ugly.unindent!(false)
98
+ assert_equal pretty, ugly.unindent!(false) unless pretty == ugly
82
99
  assert_equal pretty, ugly
83
100
  assert_equal nil, ugly.unindent!(false)
84
101
  aux = pretty.unindent(false)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heredoc_unindent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
4
+ hash: 17
5
+ prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adriano Mitre
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements: []
116
116
 
117
117
  rubyforge_project: heredoc_unindent
118
- rubygems_version: 1.4.1
118
+ rubygems_version: 1.3.7
119
119
  signing_key:
120
120
  specification_version: 3
121
121
  summary: This gem removes common margin from indented strings, such as the ones produced by indented heredocs
metadata.gz.sig CHANGED
Binary file