lovely_rufus 0.1.1 → 0.1.2

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: 1cf2ab9d43c047840510a68ef5be328bcc4f7d9b
4
- data.tar.gz: b00fee7ab10b126911a979b2925b0a761249a4cd
3
+ metadata.gz: f6cb54441bc4de2ce91a1e7b0f5ea967d62c097c
4
+ data.tar.gz: ef2d88196e57edb97ef756093996666913a6341f
5
5
  SHA512:
6
- metadata.gz: 6c933c2bf749f21e89155c550fe6a63c031a3681bb9f19083209e54d83cf979e64efcfa4e44d024b6e282eb8d61cd03bb5087ce182a89e86dbf08011efbb34a6
7
- data.tar.gz: face2858b5d1c8a25fa4a14d88f5aa37c24170a17fc09a3e68fdf6deb113e8dd4ba58ef186dbe602c65110d735c5b399c61cd65b0844fe527328aa13640035f7
6
+ metadata.gz: d7a63ba6449cb745133b335e4f43f3ff0b89e7c69f9f9ef5d50fcf5becdb49c9a8332786b723fbfd678827ea98683e0cdaf4dbd13d75e9dc65383a0b7e7f25f1
7
+ data.tar.gz: d929eb6b1d549eb0b423a6f55889290cb2b3a66096835feb9a691a8a5765b0cd53c55f3222bb610021028520a1551ac108c5bb6afc2d7b81c29d6441d9b4c66e
data/.rubocop.yml CHANGED
@@ -22,3 +22,6 @@ MethodDefParentheses:
22
22
 
23
23
  SingleLineBlockParams:
24
24
  Enabled: false
25
+
26
+ SingleSpaceBeforeFirstArg:
27
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lovely_rufus (0.1.1)
4
+ lovely_rufus (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -22,7 +22,7 @@ GEM
22
22
  celluloid-io (>= 0.15.0)
23
23
  rb-fsevent (>= 0.9.3)
24
24
  rb-inotify (>= 0.9)
25
- minitest (5.3.1)
25
+ minitest (5.3.2)
26
26
  minitest-focus (1.1.0)
27
27
  minitest (>= 4, < 6)
28
28
  nio4r (1.0.0)
@@ -31,29 +31,30 @@ GEM
31
31
  slop (~> 3.4, >= 3.4.5)
32
32
  powerpack (0.0.9)
33
33
  rainbow (2.0.0)
34
- rake (10.1.1)
34
+ rake (10.2.2)
35
35
  rb-fsevent (0.9.4)
36
36
  rb-inotify (0.9.3)
37
37
  ffi (>= 0.5.0)
38
- reek (1.3.6)
39
- ruby2ruby (~> 2.0.7)
40
- ruby_parser (~> 3.2)
38
+ reek (1.3.7)
39
+ rainbow
40
+ ruby2ruby (~> 2.0.8)
41
+ ruby_parser (~> 3.3)
41
42
  sexp_processor
42
43
  rerun (0.9.0)
43
44
  listen (~> 2.7)
44
- rubocop (0.19.1)
45
+ rubocop (0.20.1)
45
46
  json (>= 1.7.7, < 2)
46
47
  parser (~> 2.1.7)
47
48
  powerpack (~> 0.0.6)
48
49
  rainbow (>= 1.99.1, < 3.0)
49
50
  ruby-progressbar (~> 1.4)
50
51
  ruby-progressbar (1.4.2)
51
- ruby2ruby (2.0.7)
52
+ ruby2ruby (2.0.8)
52
53
  ruby_parser (~> 3.1)
53
54
  sexp_processor (~> 4.0)
54
- ruby_parser (3.4.1)
55
+ ruby_parser (3.5.0)
55
56
  sexp_processor (~> 4.1)
56
- sexp_processor (4.4.2)
57
+ sexp_processor (4.4.3)
57
58
  slop (3.5.0)
58
59
  timers (1.1.0)
59
60
 
@@ -68,4 +69,4 @@ DEPENDENCIES
68
69
  rake (~> 10.1)
69
70
  reek (~> 1.3)
70
71
  rerun (~> 0.9.0)
71
- rubocop (~> 0.19.0)
72
+ rubocop (~> 0.20.0)
data/config/reek.yml CHANGED
@@ -23,4 +23,3 @@ UncommunicativeVariableName:
23
23
  UnusedParameters:
24
24
  exclude:
25
25
  - LovelyRufus::Layer#call
26
- - LovelyRufus::OneLetterGluer#call
@@ -1,6 +1,7 @@
1
1
  module LovelyRufus class BasicWrapper < Layer
2
2
  def call wrap
3
- wrapped = wrap.text.gsub(/(.{1,#{wrap.width}})( |$\n?)/, "\\1\n")
3
+ unwrapped = wrap.text.tr("\n", ' ').strip
4
+ wrapped = unwrapped.gsub(/(.{1,#{wrap.width}})( |$\n?)/, "\\1\n")
4
5
  next_layer.call Wrap[wrapped, width: wrap.width]
5
6
  end
6
7
  end end
@@ -13,8 +13,6 @@ module LovelyRufus class CLIWrapper
13
13
  attr_reader :settings, :text_wrapper
14
14
  private :settings, :text_wrapper
15
15
 
16
- private
17
-
18
16
  class Settings
19
17
  attr_reader :width
20
18
 
@@ -16,7 +16,7 @@ module LovelyRufus class QuoteStripper < Layer
16
16
  end
17
17
 
18
18
  def quote
19
- starts = wrap.text.lines.map { |line| line[/^#{QUOTES}/] }.uniq
19
+ starts = wrap.text.lines.map { |line| line[QUOTES] }.uniq
20
20
  starts.size == 1 ? starts.first || '' : ''
21
21
  end
22
22
 
@@ -24,6 +24,6 @@ module LovelyRufus class TextWrapper
24
24
  end
25
25
 
26
26
  def paras
27
- wrap.text.split(/\n#{QUOTES}?\n/).reject { |para| para[/^#{QUOTES}?$/] }
27
+ wrap.text.split(/\n#{QUOTES}?\n/).reject { |para| para[/^(#{QUOTES}| )$/] }
28
28
  end
29
29
  end end
data/lib/lovely_rufus.rb CHANGED
@@ -9,5 +9,5 @@ require_relative 'lovely_rufus/wrap'
9
9
 
10
10
  module LovelyRufus
11
11
  NBSP = "\u00A0"
12
- QUOTES = %r{[>/#][>/# ]*}
12
+ QUOTES = /^([>\/#])(\1| )*/
13
13
  end
data/lovely_rufus.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.license = 'AGPL-3.0'
7
7
  gem.name = 'lovely_rufus'
8
8
  gem.summary = 'lovely_rufus: text wrapper'
9
- gem.version = '0.1.1'
9
+ gem.version = '0.1.2'
10
10
 
11
11
  gem.files = `git ls-files -z`.split "\0"
12
12
  gem.executables = gem.files.grep(%r{^bin/}).map { |path| File.basename path }
@@ -18,5 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.add_development_dependency 'rake', '~> 10.1'
19
19
  gem.add_development_dependency 'reek', '~> 1.3'
20
20
  gem.add_development_dependency 'rerun', '~> 0.9.0'
21
- gem.add_development_dependency 'rubocop', '~> 0.19.0'
21
+ gem.add_development_dependency 'rubocop', '~> 0.20.0'
22
22
  end
@@ -30,6 +30,15 @@ module LovelyRufus describe BasicWrapper do
30
30
  bw.call(Wrap[text, width: 5]).must_equal Wrap[wrap, width: 5]
31
31
  end
32
32
 
33
+ it 'rewraps a String from zero' do
34
+ text = <<-end.dedent
35
+ turn off
36
+ the lights and I’ll glow
37
+ 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
+
33
42
  it 'passes the fixed text to the next layer and returns its outcome' do
34
43
  final = fake :wrap
35
44
  layer = fake :layer
@@ -35,7 +35,7 @@ module LovelyRufus describe QuoteStripper do
35
35
  end
36
36
 
37
37
  it 'does not alter text contents' do
38
- wrap = Wrap['> foo > bar']
38
+ wrap = Wrap['> Ice > Ice > Baby']
39
39
  QuoteStripper.new.call(wrap).must_equal wrap
40
40
  end
41
41
 
@@ -109,5 +109,19 @@ module LovelyRufus describe QuoteStripper do
109
109
  QuoteStripper.new(layer).call Wrap[quoted, width: 72]
110
110
  layer.must_have_received :call, [Wrap[unquoted, width: 70]]
111
111
  end
112
+
113
+ it 'only considers homogenous characters as comments' do
114
+ quoted = <<-end.dedent
115
+ > /if there was a problem,
116
+ > yo – I’ll solve it!/
117
+ end
118
+ unquoted = <<-end.dedent
119
+ /if there was a problem,
120
+ yo – I’ll solve it!/
121
+ end
122
+ layer = fake :layer, call: Wrap[unquoted, width: 70]
123
+ QuoteStripper.new(layer).call Wrap[quoted, width: 72]
124
+ layer.must_have_received :call, [Wrap[unquoted, width: 70]]
125
+ end
112
126
  end
113
127
  end end
@@ -28,6 +28,14 @@ module LovelyRufus describe TextWrapper do
28
28
  end
29
29
  end
30
30
 
31
+ it 'rewraps a String from zero' do
32
+ broken = <<-end.dedent
33
+ turn off
34
+ the lights and I’ll glow
35
+ end
36
+ TextWrapper.wrap(broken).must_equal "turn off the lights and I’ll glow\n"
37
+ end
38
+
31
39
  it 'supports all the example use-cases' do
32
40
  path = File.expand_path 'text_wrapper_spec.yml', __dir__
33
41
  YAML.load_file(path).each do |spec|
@@ -34,9 +34,9 @@
34
34
  And SOMERS, who from Eastern shores imported indigo.
35
35
  output: |-
36
36
  Besides the captain and the mate, the owners and the crew,
37
- The passengers were also drowned, excepting only two:
38
- Young PETER GRAY, who tasted teas for BAKER, CROOP, AND
39
- CO., And SOMERS, who from Eastern shores imported indigo.
37
+ The passengers were also drowned, excepting only two: Young
38
+ PETER GRAY, who tasted teas for BAKER, CROOP, AND CO.,
39
+ And SOMERS, who from Eastern shores imported indigo.
40
40
 
41
41
  # one-letter words are not left at line ends
42
42
  - width: 39
@@ -46,10 +46,10 @@
46
46
  They hunted for their meals, as ALEXANDER SELKIRK used,
47
47
  But they couldn’t chat together — they had not been introduced.
48
48
  output: |-
49
- These passengers, by reason of
50
- their clinging to a mast, Upon
51
- a desert island were eventually
52
- cast. They hunted for their meals,
49
+ These passengers, by reason of their
50
+ clinging to a mast, Upon a desert
51
+ island were eventually cast.
52
+ They hunted for their meals,
53
53
  as ALEXANDER SELKIRK used, But
54
54
  they couldn’t chat together —
55
55
  they had not been introduced.
@@ -107,10 +107,10 @@
107
107
  > > >He longed to lay him down upon the shelly bed, and stuff:
108
108
  > > >He had often eaten oysters, but had never had enough.
109
109
  output: |-
110
- >>> And SOMERS sighed in sorrow as he settled in the south,
111
- >>> For the thought of PETER’S oysters brought the water to
112
- >>> his mouth. He longed to lay him down upon the shelly bed,
113
- >>> and stuff: He had often eaten oysters, but had never had enough.
110
+ >>> And SOMERS sighed in sorrow as he settled in the south, For
111
+ >>> the thought of PETER’S oysters brought the water to his mouth.
112
+ >>> He longed to lay him down upon the shelly bed, and stuff:
113
+ >>> He had often eaten oysters, but had never had enough.
114
114
 
115
115
  # quoted paragraph breaks are cleared
116
116
  - input: |-
@@ -157,8 +157,8 @@
157
157
 
158
158
  # ‘I beg your pardon—pray forgive me if I seem too bold,
159
159
  # But you have breathed a name I knew familiarly of old.
160
- # You spoke aloud of ROBINSON – I happened to be by—
161
- # You know him?’ ‘Yes, extremely well.’ ‘Allow me – so do I!’
160
+ # You spoke aloud of ROBINSON – I happened to be by— You
161
+ # know him?’ ‘Yes, extremely well.’ ‘Allow me – so do I!’
162
162
 
163
163
  It was enough: they felt they could more sociably get on,
164
164
  For (ah, the magic of the fact!) they each knew ROBINSON!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lovely_rufus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Szotkowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-21 00:00:00.000000000 Z
11
+ date: 2014-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bogus
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.19.0
103
+ version: 0.20.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.19.0
110
+ version: 0.20.0
111
111
  description: An executable and a Ruby library for wrapping paragraphs of text.
112
112
  email: chastell@chastell.net
113
113
  executables:
@@ -176,3 +176,4 @@ test_files:
176
176
  - spec/lovely_rufus/text_wrapper_spec.rb
177
177
  - spec/lovely_rufus/wrap_spec.rb
178
178
  - spec/spec_helper.rb
179
+ has_rdoc: