verse 0.2.0 → 0.2.1

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: c721dd40817c43013c05f142361a15244fe44c58
4
- data.tar.gz: c22b4b32258ea42631c727256702ff01642dd79b
3
+ metadata.gz: 8bcfae40dd0a5d6e2cfe144f7ea30d7e7ee9519b
4
+ data.tar.gz: 0b661d9f8b3850dae81afbd029eb0cd9082ab369
5
5
  SHA512:
6
- metadata.gz: 1ce1bd97ac18f78a18540c7b41f65760c71ca383f36a082e728c748957a9ca4e746774cbb8adf6d433ab523b88d226ad2a2ba0bbbfc5808b60508dd0a8142d75
7
- data.tar.gz: 39d08d89c24374654118ed3e05bff810128d94feefec1f55a49b6390db37dcae4e810e554c31749fce58890a39097227be253332ce4d20b046f8d287d1e3c20a
6
+ metadata.gz: c48ef20fbcc3013a71f92059007022d1c37a7be054710af812540e2fbb3ed5bb73b05b966eb96cf9d58fa8473ff7bc1cf3467b3b8d2aabf0df230b2dcdd3162d
7
+ data.tar.gz: 077b69e6bad26f16c461ae1f9b903cec2789f5c6f0c15c9005b2854f24c017cf3aa637c1055729d1cc2c0b570796f17ca9316cefcb7977ef1d9797af5e1fde7b
@@ -1,3 +1,8 @@
1
+ 0.2.1 (Feb 15, 2015)
2
+
3
+ * Fix empty string alignment
4
+ * Fix alignment to stop modifying original content
5
+
1
6
  0.2.0 (Feb 15, 2015)
2
7
 
3
8
  * Add unicode support
@@ -95,8 +95,9 @@ module Verse
95
95
  # @api private
96
96
  def process_lines
97
97
  lines = text.split(NEWLINE)
98
+ return yield(text) if text.empty?
98
99
  lines.reduce([]) do |aligned, line|
99
- aligned << yield(line.strip)
100
+ aligned << yield(line)
100
101
  end.join("\n")
101
102
  end
102
103
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Verse
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end # Verse
@@ -12,6 +12,11 @@ RSpec.describe Verse::Alignment, '.align' do
12
12
  }.to raise_error(ArgumentError, /Unknown alignment/)
13
13
  end
14
14
 
15
+ it "fills empty" do
16
+ alignment = Verse::Alignment.new('')
17
+ expect(alignment.center(22)).to eq(" ")
18
+ end
19
+
15
20
  it "centers line" do
16
21
  text = "the madness of men"
17
22
  alignment = Verse::Alignment.new(text)
@@ -25,7 +30,7 @@ RSpec.describe Verse::Alignment, '.align' do
25
30
  end
26
31
 
27
32
  it "centers multiline text" do
28
- text = "for there is no folly of the beast\n of the earth which\n is not infinitely\n outdone by the madness of men"
33
+ text = "for there is no folly of the beast\nof the earth which\nis not infinitely\noutdone by the madness of men"
29
34
  alignment = Verse::Alignment.new(text)
30
35
  expect(alignment.center(40)).to eq([
31
36
  " for there is no folly of the beast \n",
@@ -47,7 +52,7 @@ RSpec.describe Verse::Alignment, '.align' do
47
52
  end
48
53
 
49
54
  it "centers multiline text with fill of '*'" do
50
- text = "for there is no folly of the beast\n of the earth which\n is not infinitely\n outdone by the madness of men"
55
+ text = "for there is no folly of the beast\nof the earth which\nis not infinitely\noutdone by the madness of men"
51
56
  alignment = Verse::Alignment.new(text, fill: '*')
52
57
  expect(alignment.center(40)).to eq([
53
58
  "***for there is no folly of the beast***\n",
@@ -9,6 +9,11 @@ RSpec.describe Verse::Alignment, '.left' do
9
9
  expect(alignment.left(22)).to eq("the madness of men ")
10
10
  end
11
11
 
12
+ it "fills empty" do
13
+ alignment = Verse::Alignment.new('')
14
+ expect(alignment.left(22)).to eq(" ")
15
+ end
16
+
12
17
  it "left justifies utf line" do
13
18
  text = "こんにちは"
14
19
  alignment = Verse::Alignment.new(text)
@@ -16,7 +21,7 @@ RSpec.describe Verse::Alignment, '.left' do
16
21
  end
17
22
 
18
23
  it "aligns multiline text to left" do
19
- text = "for there is no folly of the beast\n of the earth which\n is not infinitely\n outdone by the madness of men"
24
+ text = "for there is no folly of the beast\nof the earth which\nis not infinitely\noutdone by the madness of men"
20
25
  alignment = Verse::Alignment.new(text)
21
26
  expect(alignment.left(40)).to eq([
22
27
  "for there is no folly of the beast \n",
@@ -38,7 +43,7 @@ RSpec.describe Verse::Alignment, '.left' do
38
43
  end
39
44
 
40
45
  it "centers multiline text with fill of '*'" do
41
- text = "for there is no folly of the beast\n of the earth which\n is not infinitely\n outdone by the madness of men"
46
+ text = "for there is no folly of the beast\nof the earth which\nis not infinitely\noutdone by the madness of men"
42
47
  alignment = Verse::Alignment.new(text, fill: '*')
43
48
  expect(alignment.left(40)).to eq([
44
49
  "for there is no folly of the beast******\n",
@@ -9,6 +9,11 @@ RSpec.describe Verse::Alignment, '.right' do
9
9
  expect(alignment.right(22)).to eq(" the madness of men")
10
10
  end
11
11
 
12
+ it "fills empty" do
13
+ alignment = Verse::Alignment.new('')
14
+ expect(alignment.left(22)).to eq(" ")
15
+ end
16
+
12
17
  it "right justifies utf line" do
13
18
  text = "こんにちは"
14
19
  alignment = Verse::Alignment.new(text)
@@ -38,7 +43,7 @@ RSpec.describe Verse::Alignment, '.right' do
38
43
  end
39
44
 
40
45
  it "centers multiline text with fill of '*'" do
41
- text = "for there is no folly of the beast\n of the earth which\n is not infinitely\n outdone by the madness of men"
46
+ text = "for there is no folly of the beast\nof the earth which\nis not infinitely\noutdone by the madness of men"
42
47
  alignment = Verse::Alignment.new(text, fill: '*')
43
48
  expect(alignment.right(40)).to eq([
44
49
  "******for there is no folly of the beast\n",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach