habakiri 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: 3660aa92c1546c1461461380f45ef633cbc8f35bde07cfff14364e482505319a
4
- data.tar.gz: a10e6e7c760b2e94a7ccd43e8af0c0b9d74128ad99d3683a4b1cdc4ada543c50
3
+ metadata.gz: 86dd0f177545e6a5ca9ba2f5c02ea4a80027fab802ebabd340daf2056163ffbd
4
+ data.tar.gz: 526d229d083f79d0d1306f8b65647318ee96ecccb38fc4be06d395a8f6efcffe
5
5
  SHA512:
6
- metadata.gz: 6012f69c00630c444498586c698d3fc4392567fb88cf185eaadfdd0823afe42a9169524490d01b8e7da16332a46e409575d2bfdff15c13b964f967ccd5bd8443
7
- data.tar.gz: 3dd9aba78d88b167bee0309ee56f8515deac2bc1925d9ebbcd4ab6ab9eeb2026a192a6e0f10a03cf51ddb35a0e1b927730ef5f6b63430c4413b677ee68478f9b
6
+ metadata.gz: 9b81df9121b43a1c7b8d3efdb2a83ba069dcd80cecfef57865c3a9960f52a02681ed10c1c10beb02f17ab4371377839b8d255ecaf27b8cc63c8a02f88eed1825
7
+ data.tar.gz: 03bba31509875ea42e9085e382f1734469c7950a310a2e306e7cad69690df55499f351e55f6e82107f91db55d1fa3c79f638f45994531d0a1f98638f8836a09d
@@ -31,7 +31,15 @@ class Habakiri
31
31
  end
32
32
  end
33
33
 
34
- object[key] = list.map(&:new_element).join.strip
34
+ value = list.map(&:new_element).join.strip
35
+ case object[key]
36
+ when nil
37
+ object[key] = value
38
+ when String
39
+ object[key] = [object[key], value]
40
+ when Array
41
+ object[key] << value
42
+ end
35
43
  }
36
44
  end
37
45
 
@@ -1,3 +1,3 @@
1
1
  class Habakiri
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
@@ -7,4 +7,5 @@ URL:{{url}}
7
7
  駅名:{{station}}
8
8
  メモ1:{{memo1}}
9
9
  メモ2:{{memo2}}
10
+ 空白:{{blank}}
10
11
  備考:{{note}}
@@ -0,0 +1,10 @@
1
+ 名前:{{dup}}
2
+ メールアドレス:{{dup}}
3
+ 電話番号:{{multi}}
4
+ URL:{{multi}}
5
+ 郵便番号:{{dup}}
6
+ 住所:{{dup}}
7
+ 駅名:{{alone}}
8
+ メモ1:{{multi}}
9
+ メモ2:{{multi}}
10
+ 備考:{{single}}
@@ -7,4 +7,5 @@ URL:https://example.com/path/to/homepage/1232
7
7
  駅名:東京駅
8
8
  メモ1:メモメモ
9
9
  メモ2:メモメモ2
10
+ 空白:
10
11
  備考:備考備考
@@ -0,0 +1,10 @@
1
+ 名前:テストテスト
2
+ メールアドレス:test.test@example.com
3
+ 電話番号:01201234567
4
+ URL:https://example.com/path/to/homepage/1232
5
+ 郵便番号:100-0001
6
+ 住所:東京都千代田区1-1-1
7
+ 駅名:東京駅
8
+ メモ1:メモメモ
9
+ メモ2:メモメモ2
10
+ 備考:備考備考
@@ -11,11 +11,13 @@ class HabakiriTest < Minitest::Unit::TestCase
11
11
  assert_equal('テストテスト', result['name'])
12
12
  assert_equal('test.test@example.com', result['email'])
13
13
  assert_equal('01201234567', result['tel'])
14
+ assert_equal('https://example.com/path/to/homepage/1232', result['url'])
14
15
  assert_equal('100-0001', result['zipcode'])
15
16
  assert_equal('東京都千代田区1-1-1', result['address'])
16
17
  assert_equal('東京駅', result['station'])
17
18
  assert_equal('メモメモ', result['memo1'])
18
19
  assert_equal('メモメモ2', result['memo2'])
20
+ assert_equal('', result['blank'])
19
21
  assert_equal('備考備考', result['note'])
20
22
  end
21
23
 
@@ -50,4 +52,22 @@ class HabakiriTest < Minitest::Unit::TestCase
50
52
  assert_equal('San Francisco, CA 94107 United States', result['address'])
51
53
  assert_equal("Hello, world!\nHello, ruby!\nHello, habakiri!", result['note'])
52
54
  end
55
+
56
+ def test_case_4
57
+ template = File.read('test/test_data/template_4.txt')
58
+ text = File.read('test/test_data/text_4.txt')
59
+ result = Habakiri.exec(template, text)
60
+
61
+ assert_instance_of(Hash, result)
62
+ dup = result['dup']
63
+ multi = result['multi']
64
+ alone = result['alone']
65
+ single = result['single']
66
+ assert_instance_of(Array, dup)
67
+ assert_instance_of(Array, multi)
68
+ assert_equal(['テストテスト', 'test.test@example.com', '100-0001', '東京都千代田区1-1-1'], dup)
69
+ assert_equal(['01201234567', 'https://example.com/path/to/homepage/1232', 'メモメモ', 'メモメモ2'], multi)
70
+ assert_equal('東京駅', alone)
71
+ assert_equal('備考備考', single)
72
+ end
53
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: habakiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - diaphragm
@@ -87,9 +87,11 @@ files:
87
87
  - test/test_data/template_1.txt
88
88
  - test/test_data/template_2.txt
89
89
  - test/test_data/template_3.txt
90
+ - test/test_data/template_4.txt
90
91
  - test/test_data/text_1.txt
91
92
  - test/test_data/text_2.txt
92
93
  - test/test_data/text_3.txt
94
+ - test/test_data/text_4.txt
93
95
  - test/test_habakiri.rb
94
96
  homepage: https://github.com/diaphragm/habakiri
95
97
  licenses: