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 +4 -4
- data/lib/habakiri.rb +9 -1
- data/lib/habakiri/version.rb +1 -1
- data/test/test_data/template_1.txt +1 -0
- data/test/test_data/template_4.txt +10 -0
- data/test/test_data/text_1.txt +1 -0
- data/test/test_data/text_4.txt +10 -0
- data/test/test_habakiri.rb +20 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86dd0f177545e6a5ca9ba2f5c02ea4a80027fab802ebabd340daf2056163ffbd
|
4
|
+
data.tar.gz: 526d229d083f79d0d1306f8b65647318ee96ecccb38fc4be06d395a8f6efcffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b81df9121b43a1c7b8d3efdb2a83ba069dcd80cecfef57865c3a9960f52a02681ed10c1c10beb02f17ab4371377839b8d255ecaf27b8cc63c8a02f88eed1825
|
7
|
+
data.tar.gz: 03bba31509875ea42e9085e382f1734469c7950a310a2e306e7cad69690df55499f351e55f6e82107f91db55d1fa3c79f638f45994531d0a1f98638f8836a09d
|
data/lib/habakiri.rb
CHANGED
@@ -31,7 +31,15 @@ class Habakiri
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
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
|
|
data/lib/habakiri/version.rb
CHANGED
data/test/test_data/text_1.txt
CHANGED
data/test/test_habakiri.rb
CHANGED
@@ -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.
|
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:
|