flippy 0.0.9 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61114c78f3468c896b137d2da053589b0f399804
4
- data.tar.gz: 483592a6c5effd53a93e8002270770bc982e18f7
3
+ metadata.gz: 3772f4b9c48e0aaa2f6c9a52dce645f1cd1b9c89
4
+ data.tar.gz: 430e7340d4e14a41a7cbf82fa4a55adf3d3c89a8
5
5
  SHA512:
6
- metadata.gz: 8729bb19965288a716b21faa9cc6ab878cc18732549a98f9e44f579c22a745a55c37b0de46ec78cdfc70ca5d74210676886e5e85f633a8945104459089bf9fc1
7
- data.tar.gz: 1e655215b52b3e3bb1cd3ff2dfb746bb2d09109789920ac0799b44a9ae72e263027e23a5e65d1141dfdfe05f56f6311f6c5c1e29026a87afc5f5af73b701ada1
6
+ metadata.gz: f4ce040a29b002d95a043d5de511d6e26c92e175ee8b287dab5914b0f93398d759000e72b9198060ab619e7f9918feb64a34a0fe31b7a817689bd18e08a3add7
7
+ data.tar.gz: ee2e4066224b148e329718bfff62dc0cb2cd81f8c9e226867700b83dc99c9ff582b508e041d9e21f81d8d8b3ca642f6324cce2a81c4308c27e2f61a678b3cc30
@@ -1,5 +1,8 @@
1
+ == 0.1.0 / 2013-03-20
2
+ * Flippy#vertical accept horizontal part with '//' symbol
3
+
1
4
  == 0.0.9 / 2013-03-19
2
- * Change spec to delete spaces after punctuations
5
+ * Change spec to delete spaces after punctuations for Flippy#vertical
3
6
  * Refactoring
4
7
 
5
8
  == 0.0.7-8 / 2013-03-18
@@ -1,3 +1,3 @@
1
1
  module Flippy
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -5,10 +5,22 @@ module Flippy::Vertical
5
5
  v = "|¬∟↓→↑←॥:"
6
6
  HV = (h + v)
7
7
  VH = (v + h)
8
+ H_SEP = '//'
8
9
 
10
+ # Convert to left-right vertical writing style.
11
+ #
12
+ # "Hi\nFo".vertical => "F H "
13
+ # "o i "
14
+ #
15
+ # Last part after "//" symbol is taken as a normal writing part.
16
+ #
17
+ # "Hi\nFo//by me".vertical => "F H "
18
+ # "o i by me"
19
+ #
9
20
  def vertical
10
21
  lines = []
11
- self.tr(HV, VH)
22
+ v_part, _, h_part = self.rpartition(H_SEP).reject(&:empty?)
23
+ v_part.to_s.tr(HV, VH)
12
24
  .each_line do |line|
13
25
  main_line, punc_line = [], []
14
26
  line.chomp.each_char.with_index do |chr, i|
@@ -25,6 +37,6 @@ module Flippy::Vertical
25
37
  max = lines.map(&:size).max
26
38
  lines.map { |line| line.fill(' ', line.size...max) }
27
39
  .transpose
28
- .map { |line| line.join.reverse }.join("\n")
40
+ .map { |line| line.join.reverse }.join("\n").concat("#{h_part}")
29
41
  end
30
42
  end
@@ -24,6 +24,32 @@ EOS
24
24
    ち 
25
25
    は 
26
26
    |、
27
+ EOS
28
+ end
29
+
30
+ context "vertical horizontal mix string" do
31
+ subject { "ニッポンの//自然".vertical }
32
+ it { should eq <<-EOS.chomp }
33
+ ニ 
34
+ ッ 
35
+ ポ 
36
+ ン 
37
+ の 自然
38
+ EOS
39
+ end
40
+
41
+ context "vertical horizontal mix string" do
42
+ subject { "ニッポンの//自然//大切に。".vertical }
43
+ it { should eq <<-EOS.chomp }
44
+ ニ 
45
+ ッ 
46
+ ポ 
47
+ ン 
48
+ の 
49
+ / 
50
+ / 
51
+ 自 
52
+ 然 大切に。
27
53
  EOS
28
54
  end
29
55
 
@@ -36,5 +62,13 @@ EOS
36
62
  subject { "\n".vertical }
37
63
  it { should eq "" }
38
64
  end
65
+
66
+ context "immutable test" do
67
+ it "should be immutable" do
68
+ str = "こんにちは、\n日本。"
69
+ str.vertical
70
+ str.should eq "こんにちは、\n日本。"
71
+ end
72
+ end
39
73
  end
40
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flippy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyoendo