lovely_rufus 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +12 -11
- data/config/reek.yml +0 -1
- data/lib/lovely_rufus/basic_wrapper.rb +2 -1
- data/lib/lovely_rufus/cli_wrapper.rb +0 -2
- data/lib/lovely_rufus/quote_stripper.rb +1 -1
- data/lib/lovely_rufus/text_wrapper.rb +1 -1
- data/lib/lovely_rufus.rb +1 -1
- data/lovely_rufus.gemspec +2 -2
- data/spec/lovely_rufus/basic_wrapper_spec.rb +9 -0
- data/spec/lovely_rufus/quote_stripper_spec.rb +15 -1
- data/spec/lovely_rufus/text_wrapper_spec.rb +8 -0
- data/spec/lovely_rufus/text_wrapper_spec.yml +13 -13
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6cb54441bc4de2ce91a1e7b0f5ea967d62c097c
|
4
|
+
data.tar.gz: ef2d88196e57edb97ef756093996666913a6341f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7a63ba6449cb745133b335e4f43f3ff0b89e7c69f9f9ef5d50fcf5becdb49c9a8332786b723fbfd678827ea98683e0cdaf4dbd13d75e9dc65383a0b7e7f25f1
|
7
|
+
data.tar.gz: d929eb6b1d549eb0b423a6f55889290cb2b3a66096835feb9a691a8a5765b0cd53c55f3222bb610021028520a1551ac108c5bb6afc2d7b81c29d6441d9b4c66e
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lovely_rufus (0.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.
|
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.
|
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.
|
39
|
-
|
40
|
-
|
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.
|
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.
|
52
|
+
ruby2ruby (2.0.8)
|
52
53
|
ruby_parser (~> 3.1)
|
53
54
|
sexp_processor (~> 4.0)
|
54
|
-
ruby_parser (3.
|
55
|
+
ruby_parser (3.5.0)
|
55
56
|
sexp_processor (~> 4.1)
|
56
|
-
sexp_processor (4.4.
|
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.
|
72
|
+
rubocop (~> 0.20.0)
|
data/config/reek.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module LovelyRufus class BasicWrapper < Layer
|
2
2
|
def call wrap
|
3
|
-
|
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
|
data/lib/lovely_rufus.rb
CHANGED
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.
|
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.
|
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['>
|
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
|
-
|
39
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
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
|
-
>>>
|
112
|
-
>>>
|
113
|
-
>>>
|
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
|
-
#
|
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.
|
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-
|
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.
|
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.
|
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:
|