lovely_rufus 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6cb54441bc4de2ce91a1e7b0f5ea967d62c097c
4
- data.tar.gz: ef2d88196e57edb97ef756093996666913a6341f
3
+ metadata.gz: 49c92b0710902ad7b5974120c3259511bca506b9
4
+ data.tar.gz: bacdd2b6ed4093103944c30e464defca9c88fd67
5
5
  SHA512:
6
- metadata.gz: d7a63ba6449cb745133b335e4f43f3ff0b89e7c69f9f9ef5d50fcf5becdb49c9a8332786b723fbfd678827ea98683e0cdaf4dbd13d75e9dc65383a0b7e7f25f1
7
- data.tar.gz: d929eb6b1d549eb0b423a6f55889290cb2b3a66096835feb9a691a8a5765b0cd53c55f3222bb610021028520a1551ac108c5bb6afc2d7b81c29d6441d9b4c66e
6
+ metadata.gz: 23d1be28b58049eb916bb07390880e487e81c960ad3315212de2fe396e225f695ed9f2489c3254d55efac807f88d73521d791c800b9b4211754b8d5f29978f86
7
+ data.tar.gz: 4258e4a7562d74568f4c1fa2a26df4cddf9d2b93691f8582418e931ccd8904be057ba7721e5a6992fefb7f994cb897ea5091df89f655b3b60b82b965efa3cd49
data/.rubocop.yml CHANGED
@@ -1,25 +1,13 @@
1
- AccessModifierIndentation:
2
- Enabled: false
3
-
4
1
  AndOr:
5
2
  Enabled: false
6
3
 
7
4
  Documentation:
8
5
  Enabled: false
9
6
 
10
- EndAlignment:
11
- Enabled: false
12
-
13
7
  FileName:
14
8
  Exclude:
15
9
  - bin/lovely-rufus
16
10
 
17
- IndentationWidth:
18
- Enabled: false
19
-
20
- MethodDefParentheses:
21
- EnforcedStyle: require_no_parentheses
22
-
23
11
  SingleLineBlockParams:
24
12
  Enabled: false
25
13
 
data/Gemfile.lock CHANGED
@@ -6,57 +6,55 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (1.1.0)
10
- bogus (0.1.4)
9
+ ast (2.0.0)
10
+ astrolabe (1.3.0)
11
+ parser (>= 2.2.0.pre.3, < 3.0)
12
+ bogus (0.1.5)
11
13
  dependor (>= 0.0.4)
12
- celluloid (0.15.2)
13
- timers (~> 1.1.0)
14
- celluloid-io (0.15.0)
15
- celluloid (>= 0.15.0)
16
- nio4r (>= 0.5.0)
14
+ celluloid (0.16.0)
15
+ timers (~> 4.0.0)
17
16
  dependor (1.0.1)
18
17
  ffi (1.9.3)
19
- json (1.8.1)
20
- listen (2.7.1)
18
+ hitimes (1.2.2)
19
+ listen (2.7.9)
21
20
  celluloid (>= 0.15.2)
22
- celluloid-io (>= 0.15.0)
23
21
  rb-fsevent (>= 0.9.3)
24
22
  rb-inotify (>= 0.9)
25
- minitest (5.3.2)
23
+ minitest (5.4.1)
26
24
  minitest-focus (1.1.0)
27
25
  minitest (>= 4, < 6)
28
- nio4r (1.0.0)
29
- parser (2.1.7)
30
- ast (~> 1.1)
26
+ parser (2.2.0.pre.4)
27
+ ast (>= 1.1, < 3.0)
31
28
  slop (~> 3.4, >= 3.4.5)
32
29
  powerpack (0.0.9)
33
30
  rainbow (2.0.0)
34
- rake (10.2.2)
31
+ rake (10.3.2)
35
32
  rb-fsevent (0.9.4)
36
- rb-inotify (0.9.3)
33
+ rb-inotify (0.9.5)
37
34
  ffi (>= 0.5.0)
38
- reek (1.3.7)
39
- rainbow
40
- ruby2ruby (~> 2.0.8)
35
+ reek (1.3.8)
36
+ rainbow (>= 1.99, < 3.0)
37
+ ruby2ruby (>= 2.0.8, < 3.0)
41
38
  ruby_parser (~> 3.3)
42
39
  sexp_processor
43
- rerun (0.9.0)
44
- listen (~> 2.7)
45
- rubocop (0.20.1)
46
- json (>= 1.7.7, < 2)
47
- parser (~> 2.1.7)
40
+ rerun (0.10.0)
41
+ listen (~> 2.7, >= 2.7.3)
42
+ rubocop (0.26.0)
43
+ astrolabe (~> 1.3)
44
+ parser (>= 2.2.0.pre.4, < 3.0)
48
45
  powerpack (~> 0.0.6)
49
46
  rainbow (>= 1.99.1, < 3.0)
50
47
  ruby-progressbar (~> 1.4)
51
- ruby-progressbar (1.4.2)
52
- ruby2ruby (2.0.8)
48
+ ruby-progressbar (1.5.1)
49
+ ruby2ruby (2.1.2)
53
50
  ruby_parser (~> 3.1)
54
51
  sexp_processor (~> 4.0)
55
- ruby_parser (3.5.0)
52
+ ruby_parser (3.6.2)
56
53
  sexp_processor (~> 4.1)
57
- sexp_processor (4.4.3)
58
- slop (3.5.0)
59
- timers (1.1.0)
54
+ sexp_processor (4.4.4)
55
+ slop (3.6.0)
56
+ timers (4.0.1)
57
+ hitimes
60
58
 
61
59
  PLATFORMS
62
60
  ruby
@@ -68,5 +66,5 @@ DEPENDENCIES
68
66
  minitest-focus (~> 1.1)
69
67
  rake (~> 10.1)
70
68
  reek (~> 1.3)
71
- rerun (~> 0.9.0)
72
- rubocop (~> 0.20.0)
69
+ rerun (~> 0.10.0)
70
+ rubocop (~> 0.26.0)
data/Rakefile CHANGED
@@ -2,9 +2,9 @@ require 'rake/testtask'
2
2
  require 'reek/rake/task'
3
3
  require 'rubocop/rake_task'
4
4
 
5
- task default: %i[spec rubocop reek]
5
+ task default: %i(spec rubocop reek)
6
6
 
7
- Rake::TestTask.new :spec do |task|
7
+ Rake::TestTask.new(:spec) do |task|
8
8
  task.test_files = FileList['spec/**/*_spec.rb']
9
9
  task.warning = true
10
10
  end
@@ -15,4 +15,6 @@ Reek::Rake::Task.new do |task|
15
15
  task.reek_opts = '--quiet'
16
16
  end
17
17
 
18
- Rubocop::RakeTask.new
18
+ RuboCop::RakeTask.new do |task|
19
+ task.options << '--display-cop-names'
20
+ end
data/bin/lovely-rufus CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require_relative '../lib/lovely_rufus'
4
+
4
5
  LovelyRufus::CLIWrapper.new.run
data/config/reek.yml CHANGED
@@ -1,25 +1,22 @@
1
1
  DuplicateMethodCall:
2
2
  exclude:
3
- - LovelyRufus::BasicWrapper#call
4
- - LovelyRufus::HangoutWrapper#rewrapped
3
+ - LovelyRufus::BasicWrapper#call
4
+ - LovelyRufus::HangoutWrapper#rewrapped
5
5
 
6
6
  FeatureEnvy:
7
7
  exclude:
8
- - LovelyRufus::BasicWrapper#call
9
- - LovelyRufus::HangoutWrapper#hangout_line
10
- - LovelyRufus::OneLetterGluer#call
11
- - LovelyRufus::QuoteStripper#quote
8
+ - LovelyRufus::BasicWrapper#call
9
+ - LovelyRufus::HangoutWrapper#hangout_line
10
+ - LovelyRufus::OneLetterGluer#call
11
+ - LovelyRufus::QuoteStripper#quote
12
12
 
13
13
  IrresponsibleModule:
14
14
  enabled: false
15
15
 
16
16
  NestedIterators:
17
- max_allowed_nesting: 2
18
-
19
- UncommunicativeVariableName:
20
17
  exclude:
21
- - LovelyRufus::HangoutWrapper#hangout_line
18
+ - LovelyRufus#initialize
22
19
 
23
- UnusedParameters:
20
+ UncommunicativeVariableName:
24
21
  exclude:
25
- - LovelyRufus::Layer#call
22
+ - LovelyRufus::HangoutWrapper#hangout_line
@@ -1,7 +1,12 @@
1
- module LovelyRufus class BasicWrapper < Layer
2
- def call wrap
3
- unwrapped = wrap.text.tr("\n", ' ').strip
4
- wrapped = unwrapped.gsub(/(.{1,#{wrap.width}})( |$\n?)/, "\\1\n")
5
- next_layer.call Wrap[wrapped, width: wrap.width]
1
+ require_relative 'layer'
2
+ require_relative 'wrap'
3
+
4
+ module LovelyRufus
5
+ class BasicWrapper < Layer
6
+ def call(wrap)
7
+ unwrapped = wrap.text.tr("\n", ' ').strip
8
+ wrapped = unwrapped.gsub(/(.{1,#{wrap.width}})( |$\n?)/, "\\1\n")
9
+ next_layer.call(Wrap[wrapped, width: wrap.width])
10
+ end
6
11
  end
7
- end end
12
+ end
@@ -1,28 +1,18 @@
1
- require 'optparse'
1
+ require_relative 'settings'
2
+ require_relative 'text_wrapper'
2
3
 
3
- module LovelyRufus class CLIWrapper
4
- def initialize args = ARGV, text_wrapper: TextWrapper
5
- @settings = Settings.new args
6
- @text_wrapper = text_wrapper
7
- end
8
-
9
- def run stream = $stdin
10
- puts text_wrapper.wrap stream.read, width: settings.width
11
- end
12
-
13
- attr_reader :settings, :text_wrapper
14
- private :settings, :text_wrapper
15
-
16
- class Settings
17
- attr_reader :width
4
+ module LovelyRufus
5
+ class CLIWrapper
6
+ def initialize(args = ARGV, text_wrapper: TextWrapper)
7
+ @settings = Settings.new(args)
8
+ @text_wrapper = text_wrapper
9
+ end
18
10
 
19
- def initialize args
20
- @width = 72
21
- OptionParser.new do |opts|
22
- opts.on '-w', '--width WIDTH', Integer, 'Wrapping width' do |width|
23
- @width = width
24
- end
25
- end.parse! args
11
+ def run(stream = $stdin)
12
+ puts text_wrapper.wrap(stream.read, width: settings.width)
26
13
  end
14
+
15
+ attr_reader :settings, :text_wrapper
16
+ private :settings, :text_wrapper
27
17
  end
28
- end end
18
+ end
@@ -1,32 +1,38 @@
1
- module LovelyRufus class HangoutWrapper < Layer
2
- def call wrap
3
- @wrap = wrap
4
- final = hangout_line ? rewrapped : wrap.text
5
- next_layer.call Wrap[final, width: wrap.width]
6
- end
1
+ require_relative 'basic_wrapper'
2
+ require_relative 'layer'
3
+ require_relative 'wrap'
4
+
5
+ module LovelyRufus
6
+ class HangoutWrapper < Layer
7
+ def call(wrap)
8
+ @wrap = wrap
9
+ final = hangout_line ? rewrapped : wrap.text
10
+ next_layer.call(Wrap[final, width: wrap.width])
11
+ end
7
12
 
8
- attr_reader :wrap
9
- private :wrap
13
+ attr_reader :wrap
14
+ private :wrap
10
15
 
11
- private
16
+ private
12
17
 
13
- def hangout_line
14
- lines.each_cons 2 do |a, b|
15
- return a if a[/\p{space}/] and a.rindex(/\p{space}/) >= b.size
16
- unless b == lines.last
17
- return b if b[/\p{space}/] and b.rindex(/\p{space}/) >= a.size
18
+ def hangout_line
19
+ lines.each_cons(2) do |a, b|
20
+ return a if a[/\p{space}/] and a.rindex(/\p{space}/) >= b.size
21
+ unless b == lines.last
22
+ return b if b[/\p{space}/] and b.rindex(/\p{space}/) >= a.size
23
+ end
18
24
  end
19
25
  end
20
- end
21
26
 
22
- def lines
23
- @lines ||= wrap.text.lines.map(&:chomp)
24
- end
27
+ def lines
28
+ @lines ||= wrap.text.lines.map(&:chomp)
29
+ end
25
30
 
26
- def rewrapped
27
- hangout_line << NBSP
28
- unfolded = lines.join(' ').gsub("#{NBSP} ", NBSP)
29
- wrapped = BasicWrapper.new.call(Wrap[unfolded, width: wrap.width]).text
30
- HangoutWrapper.new.call(Wrap[wrapped, width: wrap.width]).text
31
+ def rewrapped
32
+ hangout_line << NBSP
33
+ unfolded = lines.join(' ').gsub("#{NBSP} ", NBSP)
34
+ wrapped = BasicWrapper.new.call(Wrap[unfolded, width: wrap.width]).text
35
+ HangoutWrapper.new.call(Wrap[wrapped, width: wrap.width]).text
36
+ end
31
37
  end
32
- end end
38
+ end
@@ -1,12 +1,14 @@
1
- module LovelyRufus class Layer
2
- def initialize next_layer = -> wrap { wrap }
3
- @next_layer = next_layer
4
- end
1
+ module LovelyRufus
2
+ class Layer
3
+ def initialize(next_layer = -> (wrap) { wrap })
4
+ @next_layer = next_layer
5
+ end
5
6
 
6
- def call opts = {}
7
- fail 'Layer subclasses must define #call'
8
- end
7
+ def call(_opts = {})
8
+ fail 'Layer subclasses must define #call'
9
+ end
9
10
 
10
- attr_reader :next_layer
11
- private :next_layer
12
- end end
11
+ attr_reader :next_layer
12
+ private :next_layer
13
+ end
14
+ end
@@ -1,7 +1,12 @@
1
- module LovelyRufus class OneLetterGluer < Layer
2
- def call wrap
3
- pattern = /(?<=\p{space})(&|\p{letter})\p{space}/
4
- text = wrap.text.gsub pattern, "\\1\\2#{NBSP}"
5
- next_layer.call Wrap[text, width: wrap.width]
1
+ require_relative 'layer'
2
+ require_relative 'wrap'
3
+
4
+ module LovelyRufus
5
+ class OneLetterGluer < Layer
6
+ def call(wrap)
7
+ pattern = /(?<=\p{space})(&|\p{letter})\p{space}/
8
+ text = wrap.text.gsub(pattern, "\\1\\2#{NBSP}")
9
+ next_layer.call(Wrap[text, width: wrap.width])
10
+ end
6
11
  end
7
- end end
12
+ end
@@ -1,27 +1,32 @@
1
- module LovelyRufus class QuoteStripper < Layer
2
- def call wrap
3
- @wrap = wrap
4
- wrapped = next_layer.call stripped_wrap
5
- quoted = wrapped.text.lines.map { |line| fixed_quote + line }.join
6
- Wrap[quoted, width: wrapped.width + fixed_quote.size]
7
- end
1
+ require_relative 'layer'
2
+ require_relative 'wrap'
8
3
 
9
- attr_reader :wrap
10
- private :wrap
4
+ module LovelyRufus
5
+ class QuoteStripper < Layer
6
+ def call(wrap)
7
+ @wrap = wrap
8
+ wrapped = next_layer.call(stripped_wrap)
9
+ quoted = wrapped.text.lines.map { |line| fixed_quote + line }.join
10
+ Wrap[quoted, width: wrapped.width + fixed_quote.size]
11
+ end
11
12
 
12
- private
13
+ attr_reader :wrap
14
+ private :wrap
13
15
 
14
- def fixed_quote
15
- quote.size > 0 ? quote.delete(' ') + ' ' : ''
16
- end
16
+ private
17
17
 
18
- def quote
19
- starts = wrap.text.lines.map { |line| line[QUOTES] }.uniq
20
- starts.size == 1 ? starts.first || '' : ''
21
- end
18
+ def fixed_quote
19
+ quote.size > 0 ? quote.delete(' ') + ' ' : ''
20
+ end
21
+
22
+ def quote
23
+ starts = wrap.text.lines.map { |line| line[QUOTES] }.uniq
24
+ starts.size == 1 ? starts.first || '' : ''
25
+ end
22
26
 
23
- def stripped_wrap
24
- stripped_text = wrap.text.lines.map { |line| line[quote.size..-1] }.join
25
- Wrap[stripped_text, width: wrap.width - fixed_quote.size]
27
+ def stripped_wrap
28
+ stripped_text = wrap.text.lines.map { |line| line[quote.size..-1] }.join
29
+ Wrap[stripped_text, width: wrap.width - fixed_quote.size]
30
+ end
26
31
  end
27
- end end
32
+ end
@@ -0,0 +1,14 @@
1
+ require 'optparse'
2
+
3
+ module LovelyRufus
4
+ Settings = Struct.new(:width) do
5
+ def initialize(args)
6
+ self.width = 72
7
+ OptionParser.new do |opts|
8
+ opts.on('-w', '--width=WIDTH', Integer, 'Wrapping width') do |width|
9
+ self.width = width
10
+ end
11
+ end.parse! args
12
+ end
13
+ end
14
+ end
@@ -1,29 +1,38 @@
1
- module LovelyRufus class TextWrapper
2
- def self.wrap text, width: 72
3
- new(Wrap[text, width: width]).call
4
- end
1
+ require_relative 'basic_wrapper'
2
+ require_relative 'hangout_wrapper'
3
+ require_relative 'one_letter_gluer'
4
+ require_relative 'quote_stripper'
5
+ require_relative 'wrap'
5
6
 
6
- def initialize wrap
7
- @wrap = wrap
8
- end
7
+ module LovelyRufus
8
+ class TextWrapper
9
+ def self.wrap(text, width: 72)
10
+ new(Wrap[text, width: width]).call
11
+ end
9
12
 
10
- def call
11
- paras.map do |para|
12
- chain.call(Wrap[para, width: wrap.width]).text.tr NBSP, ' '
13
- end.join "\n"
14
- end
13
+ def initialize(wrap)
14
+ @wrap = wrap
15
+ end
15
16
 
16
- attr_reader :wrap
17
- private :wrap
17
+ def call
18
+ paras.map do |para|
19
+ chain.call(Wrap[para, width: wrap.width]).text.tr(NBSP, ' ')
20
+ end.join("\n")
21
+ end
18
22
 
19
- private
23
+ attr_reader :wrap
24
+ private :wrap
20
25
 
21
- def chain
22
- layers = [QuoteStripper, OneLetterGluer, BasicWrapper, HangoutWrapper]
23
- layers.reverse.reduce(-> wrap { wrap }) { |inner, outer| outer.new inner }
24
- end
26
+ private
27
+
28
+ def chain
29
+ layers = [QuoteStripper, OneLetterGluer, BasicWrapper, HangoutWrapper]
30
+ identity = -> (wrap) { wrap }
31
+ layers.reverse.reduce(identity) { |inner, outer| outer.new(inner) }
32
+ end
25
33
 
26
- def paras
27
- wrap.text.split(/\n#{QUOTES}?\n/).reject { |para| para[/^(#{QUOTES}| )$/] }
34
+ def paras
35
+ wrap.text.split(/\n#{QUOTES}?\n/).reject { |par| par[/^(#{QUOTES}| )$/] }
36
+ end
28
37
  end
29
- end end
38
+ end
@@ -1,10 +1,7 @@
1
1
  module LovelyRufus
2
- Wrap = Struct.new :text, :width do
3
- class << self
4
- undef []
5
- def [] text = '', width: 72
6
- new text, width
7
- end
2
+ Wrap = Struct.new(:text, :width) do
3
+ def initialize(text = '', width: 72)
4
+ super text, width
8
5
  end
9
6
  end
10
7
  end
data/lib/lovely_rufus.rb CHANGED
@@ -1,13 +1,11 @@
1
- require_relative 'lovely_rufus/layer'
2
- require_relative 'lovely_rufus/basic_wrapper'
3
- require_relative 'lovely_rufus/cli_wrapper'
4
- require_relative 'lovely_rufus/hangout_wrapper'
5
- require_relative 'lovely_rufus/one_letter_gluer'
6
- require_relative 'lovely_rufus/quote_stripper'
7
- require_relative 'lovely_rufus/text_wrapper'
8
- require_relative 'lovely_rufus/wrap'
9
-
10
1
  module LovelyRufus
11
2
  NBSP = "\u00A0"
12
3
  QUOTES = /^([>\/#])(\1| )*/
4
+
5
+ def self.wrap(text, width: 72)
6
+ TextWrapper.wrap(text, width: width)
7
+ end
13
8
  end
9
+
10
+ require_relative 'lovely_rufus/cli_wrapper'
11
+ require_relative 'lovely_rufus/text_wrapper'
data/lovely_rufus.gemspec CHANGED
@@ -1,22 +1,23 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.author = 'Piotr Szotkowski'
3
- gem.description = 'An executable and a Ruby library for wrapping paragraphs of text.'
3
+ gem.description = 'An executable and a Ruby library for wrapping ' \
4
+ 'paragraphs of text.'
4
5
  gem.email = 'chastell@chastell.net'
5
6
  gem.homepage = 'http://github.com/chastell/lovely_rufus'
6
7
  gem.license = 'AGPL-3.0'
7
8
  gem.name = 'lovely_rufus'
8
9
  gem.summary = 'lovely_rufus: text wrapper'
9
- gem.version = '0.1.2'
10
+ gem.version = '0.2.0'
10
11
 
11
- gem.files = `git ls-files -z`.split "\0"
12
- gem.executables = gem.files.grep(%r{^bin/}).map { |path| File.basename path }
13
- gem.test_files = gem.files.grep %r{^spec/.*\.rb$}
12
+ gem.files = `git ls-files -z`.split("\0")
13
+ gem.executables = gem.files.grep(/^bin\//).map { |path| File.basename(path) }
14
+ gem.test_files = gem.files.grep(/^spec\/.*\.rb$/)
14
15
 
15
16
  gem.add_development_dependency 'bogus', '~> 0.1.4'
16
17
  gem.add_development_dependency 'minitest', '~> 5.0'
17
18
  gem.add_development_dependency 'minitest-focus', '~> 1.1'
18
19
  gem.add_development_dependency 'rake', '~> 10.1'
19
20
  gem.add_development_dependency 'reek', '~> 1.3'
20
- gem.add_development_dependency 'rerun', '~> 0.9.0'
21
- gem.add_development_dependency 'rubocop', '~> 0.20.0'
21
+ gem.add_development_dependency 'rerun', '~> 0.10.0'
22
+ gem.add_development_dependency 'rubocop', '~> 0.26.0'
22
23
  end
@@ -1,49 +1,53 @@
1
1
  require_relative '../spec_helper'
2
+ require_relative '../../lib/lovely_rufus/basic_wrapper'
3
+ require_relative '../../lib/lovely_rufus/wrap'
2
4
 
3
- module LovelyRufus describe BasicWrapper do
4
- describe '#call' do
5
- it 'wraps text to the given width' do
6
- text = 'I go crazy when I hear a cymbal and a hi-hat ' \
7
- 'with a souped-up tempo'
8
- wrap = <<-end.dedent
9
- I go crazy when I hear
10
- a cymbal and a hi-hat
11
- with a souped-up tempo
5
+ module LovelyRufus
6
+ describe BasicWrapper do
7
+ describe '#call' do
8
+ it 'wraps text to the given width' do
9
+ text = 'I go crazy when I hear a cymbal and a hi-hat ' \
10
+ 'with a souped-up tempo'
11
+ wrap = <<-end.dedent
12
+ I go crazy when I hear
13
+ a cymbal and a hi-hat
14
+ with a souped-up tempo
15
+ end
16
+ bw = BasicWrapper.new
17
+ bw.call(Wrap[text, width: 22]).must_equal Wrap[wrap, width: 22]
12
18
  end
13
- bw = BasicWrapper.new
14
- bw.call(Wrap[text, width: 22]).must_equal Wrap[wrap, width: 22]
15
- end
16
19
 
17
- it 'extends past the given width when necessary' do
18
- text = 'I’m killing your brain like a poisonous mushroom'
19
- wrap = <<-end.dedent
20
- I’m
21
- killing
22
- your
23
- brain
24
- like
25
- a
26
- poisonous
27
- mushroom
20
+ it 'extends past the given width when necessary' do
21
+ text = 'I’m killing your brain like a poisonous mushroom'
22
+ wrap = <<-end.dedent
23
+ I’m
24
+ killing
25
+ your
26
+ brain
27
+ like
28
+ a
29
+ poisonous
30
+ mushroom
31
+ end
32
+ bw = BasicWrapper.new
33
+ bw.call(Wrap[text, width: 5]).must_equal Wrap[wrap, width: 5]
28
34
  end
29
- bw = BasicWrapper.new
30
- bw.call(Wrap[text, width: 5]).must_equal Wrap[wrap, width: 5]
31
- end
32
35
 
33
- it 'rewraps a String from zero' do
34
- text = <<-end.dedent
35
- turn off
36
- the lights and I’ll glow
36
+ it 'rewraps a String from zero' do
37
+ text = <<-end.dedent
38
+ turn off
39
+ the lights and I’ll glow
40
+ end
41
+ wrap = "turn off the lights and I’ll glow\n"
42
+ BasicWrapper.new.call(Wrap[text]).must_equal Wrap[wrap]
37
43
  end
38
- wrap = "turn off the lights and I’ll glow\n"
39
- BasicWrapper.new.call(Wrap[text]).must_equal Wrap[wrap]
40
- end
41
44
 
42
- it 'passes the fixed text to the next layer and returns its outcome' do
43
- final = fake :wrap
44
- layer = fake :layer
45
- mock(layer).call(Wrap["I\nO\nU\n", width: 2]) { final }
46
- BasicWrapper.new(layer).call(Wrap['I O U', width: 2]).must_equal final
45
+ it 'passes the fixed text to the next layer and returns its outcome' do
46
+ final = fake(:wrap)
47
+ layer = fake(:layer)
48
+ mock(layer).call(Wrap["I\nO\nU\n", width: 2]) { final }
49
+ BasicWrapper.new(layer).call(Wrap['I O U', width: 2]).must_equal final
50
+ end
47
51
  end
48
52
  end
49
- end end
53
+ end