flippy 0.0.8 → 0.0.9

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: 2ac32b046bd9e616d2a792b80f1ac7a596dcd4ae
4
- data.tar.gz: a9ee303090506ecceabd43544db5607ac335fc3a
3
+ metadata.gz: 61114c78f3468c896b137d2da053589b0f399804
4
+ data.tar.gz: 483592a6c5effd53a93e8002270770bc982e18f7
5
5
  SHA512:
6
- metadata.gz: 7d61a1ad9a28d39cadea03b50383133f575edbc19a29754d6f7a399a52440059dc45caff8f597fbf2e9a09c5d2abd8e83d2b533134440a4d75e720b41f71b936
7
- data.tar.gz: 761fb2f023a3a26762d230783808a7f46469fa9462d2ebaa56a69a4c080b83aee025df09ca14edcd42e6b46e7549bf90c7cf8bb87ba329f4cd54251bc1f4579e
6
+ metadata.gz: 8729bb19965288a716b21faa9cc6ab878cc18732549a98f9e44f579c22a745a55c37b0de46ec78cdfc70ca5d74210676886e5e85f633a8945104459089bf9fc1
7
+ data.tar.gz: 1e655215b52b3e3bb1cd3ff2dfb746bb2d09109789920ac0799b44a9ae72e263027e23a5e65d1141dfdfe05f56f6311f6c5c1e29026a87afc5f5af73b701ada1
@@ -1,3 +1,7 @@
1
+ == 0.0.9 / 2013-03-19
2
+ * Change spec to delete spaces after punctuations
3
+ * Refactoring
4
+
1
5
  == 0.0.7-8 / 2013-03-18
2
6
  * Bug Fixes
3
7
 
@@ -1,3 +1,3 @@
1
1
  module Flippy
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -1,37 +1,30 @@
1
1
  # encoding: UTF-8
2
2
  module Flippy::Vertical
3
- PUNC = ["","","",""]
4
-
5
- SYM = {
6
- "ー" => "|",
7
- "「" => "¬",
8
- "」" => "∟",
9
- "→" => "↓",
10
- "↑" => "→",
11
- "←" => "↑",
12
- "↓" => "←",
13
- "=" => "॥",
14
- "…" => ":"
15
- }
16
-
17
- SYM1 = (SYM.keys + SYM.values).join
18
- SYM2 = (SYM.values + SYM.keys).join
3
+ PUNC = %w( )
4
+ h = "ー「」→↑←↓=…"
5
+ v = "|¬∟↓→↑←॥:"
6
+ HV = (h + v)
7
+ VH = (v + h)
19
8
 
20
9
  def vertical
21
10
  lines = []
22
- self.tr(SYM1, SYM2)
23
- .each_line { |line|
24
- line.chomp!
25
- top = line[0] || ""
26
- rest = line[1..-1] || ""
27
- lines << rest.gsub(/[^#{PUNC.join}]/, ' ')
28
- lines << top + rest.gsub(/#{PUNC.join("|")}/, ' ')
29
- }
11
+ self.tr(HV, VH)
12
+ .each_line do |line|
13
+ main_line, punc_line = [], []
14
+ line.chomp.each_char.with_index do |chr, i|
15
+ if i.zero? || !PUNC.include?(chr)
16
+ main_line << chr
17
+ punc_line << ' '
18
+ else
19
+ punc_line[-1] = chr
20
+ end
21
+ end
22
+ lines << punc_line << main_line
23
+ end
30
24
 
31
25
  max = lines.map(&:size).max
32
- lines.map { |line|
33
- Array.new(max, ' ').tap { |arr| arr[0, line.size] = line.split(//) }
34
- }.transpose
26
+ lines.map { |line| line.fill(' ', line.size...max) }
27
+ .transpose
35
28
  .map { |line| line.join.reverse }.join("\n")
36
29
  end
37
30
  end
@@ -12,7 +12,6 @@ describe Flippy do
12
12
    ち 
13
13
    は 
14
14
    |、
15
-     
16
15
  EOS
17
16
  end
18
17
 
@@ -21,11 +20,10 @@ EOS
21
20
  it { should eq <<-EOS.chomp }
22
21
  日 こ 
23
22
  本。ん 
24
-   に 
25
- 人。ち 
23
+ 人。に 
24
+   ち 
26
25
    は 
27
26
    |、
28
-     
29
27
  EOS
30
28
  end
31
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flippy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyoendo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-18 00:00:00.000000000 Z
11
+ date: 2013-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop