lovely_rufus 0.1.0

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.
@@ -0,0 +1,166 @@
1
+ # returns unwrapped input if it’s short enough
2
+ - input: ‘Etiquette’ by Sir William Schwenck Gilbert
3
+ output: ‘Etiquette’ by Sir William Schwenck Gilbert
4
+
5
+ # wraps short input if requested to wrap it shorter, avoiding hangouts
6
+ - width: 16
7
+ input: ‘Etiquette’ by Sir William Schwenck Gilbert
8
+ output: |-
9
+ ‘Etiquette’
10
+ by Sir William
11
+ Schwenck Gilbert
12
+
13
+ # wraps long input to 72 characters by default, targetting similar line length
14
+ - input: The Ballyshannon foundered off the coast of Cariboo, And down in fathoms many went the captain and the crew;
15
+ output: |-
16
+ The Ballyshannon foundered off the coast of Cariboo,
17
+ And down in fathoms many went the captain and the crew;
18
+
19
+ # rewraps multiline paragraphs
20
+ - input: |-
21
+ Down went the owners — greedy men
22
+ whom hope of gain allured:
23
+ Oh, dry the starting tear,
24
+ for they were heavily insured.
25
+ output: |-
26
+ Down went the owners — greedy men whom hope of gain allured:
27
+ Oh, dry the starting tear, for they were heavily insured.
28
+
29
+ # wrapped paragraphs are as short as possible
30
+ - input: |-
31
+ Besides the captain and the mate, the owners and the crew,
32
+ The passengers were also drowned, excepting only two:
33
+ Young PETER GRAY, who tasted teas for BAKER, CROOP, AND CO.,
34
+ And SOMERS, who from Eastern shores imported indigo.
35
+ output: |-
36
+ Besides the captain and the mate, the owners and the crew,
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
+
41
+ # one-letter words are not left at line ends
42
+ - width: 39
43
+ input: |-
44
+ These passengers, by reason of their clinging to a mast,
45
+ Upon a desert island were eventually cast.
46
+ They hunted for their meals, as ALEXANDER SELKIRK used,
47
+ But they couldn’t chat together — they had not been introduced.
48
+ output: |-
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
+ as ALEXANDER SELKIRK used, But
54
+ they couldn’t chat together —
55
+ they had not been introduced.
56
+
57
+ # multiple paragraphs are wrapped independently
58
+ - input: |-
59
+ For PETER GRAY, and SOMERS too, though certainly in trade,
60
+ Were properly particular about the friends they made;
61
+ And somehow thus they settled it without a word of mouth —
62
+ That GRAY should take the northern half while SOMERS took the south.
63
+
64
+ On PETER’S portion oysters grew — a delicacy rare,
65
+ But oysters were a delicacy PETER couldn’t bear.
66
+ On SOMERS’ side was turtle, on the shingle lying thick,
67
+ Which SOMERS couldn’t eat, because it always made him sick.
68
+ output: |-
69
+ For PETER GRAY, and SOMERS too, though certainly in trade, Were
70
+ properly particular about the friends they made; And somehow
71
+ thus they settled it without a word of mouth — That GRAY
72
+ should take the northern half while SOMERS took the south.
73
+
74
+ On PETER’S portion oysters grew — a delicacy rare, But
75
+ oysters were a delicacy PETER couldn’t bear. On SOMERS’
76
+ side was turtle, on the shingle lying thick, Which
77
+ SOMERS couldn’t eat, because it always made him sick.
78
+
79
+ # email-quoted paragraphs are wrapped regardless of quotes
80
+ - input: |-
81
+ > On PETER’S portion oysters grew — a delicacy rare,
82
+ > But oysters were a delicacy PETER couldn’t bear.
83
+ > On SOMERS’ side was turtle, on the shingle lying thick,
84
+ > Which SOMERS couldn’t eat, because it always made him sick.
85
+ output: |-
86
+ > On PETER’S portion oysters grew — a delicacy rare, But
87
+ > oysters were a delicacy PETER couldn’t bear. On SOMERS’
88
+ > side was turtle, on the shingle lying thick, Which
89
+ > SOMERS couldn’t eat, because it always made him sick.
90
+
91
+ # email quotes can be of any depth
92
+ - input: |-
93
+ >> GRAY gnashed his teeth with envy as he saw a mighty store
94
+ >> Of turtle unmolested on his fellow-creature’s shore:
95
+ >> The oysters at his feet aside impatiently he shoved,
96
+ >> For turtle and his mother were the only things he loved.
97
+ output: |-
98
+ >> GRAY gnashed his teeth with envy as he saw a mighty store
99
+ >> Of turtle unmolested on his fellow-creature’s shore:
100
+ >> The oysters at his feet aside impatiently he shoved,
101
+ >> For turtle and his mother were the only things he loved.
102
+
103
+ # email quotes are normalised upon wrapping
104
+ - input: |-
105
+ > > >And SOMERS sighed in sorrow as he settled in the south,
106
+ > > >For the thought of PETER’S oysters brought the water to his mouth.
107
+ > > >He longed to lay him down upon the shelly bed, and stuff:
108
+ > > >He had often eaten oysters, but had never had enough.
109
+ output: |-
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
+
115
+ # quoted paragraph breaks are cleared
116
+ - input: |-
117
+ >> How they wished an introduction to each other they had had
118
+ >> When on board The Ballyshannon! And it drove them nearly mad
119
+ >> To think how very friendly with each other they might get,
120
+ >> If it wasn’t for the arbitrary rule of etiquette!
121
+ >
122
+ > One day, when out a-hunting for the mus ridiculus,
123
+ > GRAY overheard his fellow-man soliloquising thus:
124
+ > ‘I wonder how the playmates of my youth are getting on,
125
+ > MCCONNELL, S. B. WALTERS, PADDY BYLES, and ROBINSON?’
126
+ output: |-
127
+ >> How they wished an introduction to each other they had had
128
+ >> When on board The Ballyshannon! And it drove them nearly
129
+ >> mad To think how very friendly with each other they might
130
+ >> get, If it wasn’t for the arbitrary rule of etiquette!
131
+
132
+ > One day, when out a-hunting for the mus ridiculus, GRAY overheard his
133
+ > fellow-man soliloquising thus: ‘I wonder how the playmates of my youth
134
+ > are getting on, MCCONNELL, S. B. WALTERS, PADDY BYLES, and ROBINSON?’
135
+
136
+ # code comments are handled like email-quoted text
137
+ - input: |-
138
+ // These simple words made PETER as delighted as could be,
139
+ // Old chummies at the Charterhouse were ROBINSON and he!
140
+ // He walked straight up to SOMERS, then he turned extremely red,
141
+ // Hesitated, hummed and hawed a bit, then cleared his throat, and said:
142
+ //
143
+ # ‘I beg your pardon—pray forgive me if I seem too bold,
144
+ # But you have breathed a name I knew familiarly of old.
145
+ # You spoke aloud of ROBINSON – I happened to be by—
146
+ # You know him?’ ‘Yes, extremely well.’ ‘Allow me – so do I!’
147
+ #
148
+ It was enough: they felt they could more sociably get on,
149
+ For (ah, the magic of the fact!) they each knew ROBINSON!
150
+ And MR. SOMERS’ turtle was at PETER’S service quite,
151
+ And MR. SOMERS punished PETER’S oyster-beds all night.
152
+ output: |-
153
+ // These simple words made PETER as delighted as could be, Old chummies
154
+ // at the Charterhouse were ROBINSON and he! He walked straight
155
+ // up to SOMERS, then he turned extremely red, Hesitated,
156
+ // hummed and hawed a bit, then cleared his throat, and said:
157
+
158
+ # ‘I beg your pardon—pray forgive me if I seem too bold,
159
+ # But you have breathed a name I knew familiarly of old.
160
+ # You spoke aloud of ROBINSON – I happened to be by— You
161
+ # know him?’ ‘Yes, extremely well.’ ‘Allow me – so do I!’
162
+
163
+ It was enough: they felt they could more sociably get on,
164
+ For (ah, the magic of the fact!) they each knew ROBINSON!
165
+ And MR. SOMERS’ turtle was at PETER’S service quite,
166
+ And MR. SOMERS punished PETER’S oyster-beds all night.
@@ -0,0 +1,27 @@
1
+ require_relative '../spec_helper'
2
+
3
+ module LovelyRufus describe Wrap do
4
+ describe '.[]' do
5
+ it 'creates a Wrap with the given text and target width' do
6
+ Wrap['Ice Ice Baby', width: 7].text.must_equal 'Ice Ice Baby'
7
+ Wrap['Ice Ice Baby', width: 7].width.must_equal 7
8
+ end
9
+
10
+ it 'defaults to empty text and width of 72' do
11
+ Wrap[].text.must_equal ''
12
+ Wrap[].width.must_equal 72
13
+ end
14
+ end
15
+
16
+ describe '#text' do
17
+ it 'accesses the text of the Wrap' do
18
+ Wrap['Ice Ice Baby', width: 7].text.must_equal 'Ice Ice Baby'
19
+ end
20
+ end
21
+
22
+ describe '#width' do
23
+ it 'accesses the target width of the Wrap' do
24
+ Wrap['Ice Ice Baby', width: 7].width.must_equal 7
25
+ end
26
+ end
27
+ end end
@@ -0,0 +1,15 @@
1
+ require 'bundler/setup'
2
+ require 'minitest/autorun'
3
+ require 'minitest/focus'
4
+ require 'minitest/pride'
5
+ require 'bogus/minitest/spec'
6
+ require 'yaml'
7
+ require 'lovely_rufus'
8
+
9
+ Bogus.configure { |config| config.search_modules << LovelyRufus }
10
+
11
+ class String
12
+ def dedent
13
+ gsub(/^#{self[/\A\s*/]}/, '')
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lovely_rufus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Piotr Szotkowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bogus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.4
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest-focus
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: reek
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.18.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.18.0
83
+ description: An executable and a Ruby library for wrapping paragraphs of text.
84
+ email: chastell@chastell.net
85
+ executables:
86
+ - lovely-rufus
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".rubocop.yml"
91
+ - ".ruby-version"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENCE
95
+ - README.md
96
+ - Rakefile
97
+ - bin/lovely-rufus
98
+ - config/reek.yml
99
+ - lib/lovely_rufus.rb
100
+ - lib/lovely_rufus/basic_wrapper.rb
101
+ - lib/lovely_rufus/cli_wrapper.rb
102
+ - lib/lovely_rufus/hangout_wrapper.rb
103
+ - lib/lovely_rufus/layer.rb
104
+ - lib/lovely_rufus/one_letter_gluer.rb
105
+ - lib/lovely_rufus/quote_stripper.rb
106
+ - lib/lovely_rufus/text_wrapper.rb
107
+ - lib/lovely_rufus/wrap.rb
108
+ - lovely_rufus.gemspec
109
+ - spec/lovely_rufus/basic_wrapper_spec.rb
110
+ - spec/lovely_rufus/cli_wrapper_spec.rb
111
+ - spec/lovely_rufus/hangout_wrapper_spec.rb
112
+ - spec/lovely_rufus/one_letter_gluer_spec.rb
113
+ - spec/lovely_rufus/quote_stripper_spec.rb
114
+ - spec/lovely_rufus/text_wrapper_spec.rb
115
+ - spec/lovely_rufus/text_wrapper_spec.yml
116
+ - spec/lovely_rufus/wrap_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: http://github.com/chastell/lovely_rufus
119
+ licenses:
120
+ - AGPL-3.0
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.2.0
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: 'lovely_rufus: text wrapper'
142
+ test_files:
143
+ - spec/lovely_rufus/basic_wrapper_spec.rb
144
+ - spec/lovely_rufus/cli_wrapper_spec.rb
145
+ - spec/lovely_rufus/hangout_wrapper_spec.rb
146
+ - spec/lovely_rufus/one_letter_gluer_spec.rb
147
+ - spec/lovely_rufus/quote_stripper_spec.rb
148
+ - spec/lovely_rufus/text_wrapper_spec.rb
149
+ - spec/lovely_rufus/wrap_spec.rb
150
+ - spec/spec_helper.rb