ita2 0.1.0 → 0.1.1
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.
- data/lib/ita2.rb +9 -0
- data/test/ita2_test.rb +28 -1
- metadata +3 -3
data/lib/ita2.rb
CHANGED
@@ -85,4 +85,13 @@ class String
|
|
85
85
|
def to_punchcode(on = "#", off = "\s")
|
86
86
|
pretty_string(self, on, off)
|
87
87
|
end
|
88
|
+
|
89
|
+
def invalid_letters?
|
90
|
+
invalid = 0
|
91
|
+
self.downcase.each_char do |char|
|
92
|
+
invalid += 1 unless FIGS.include?(char) or LTRS.include?(char)
|
93
|
+
end
|
94
|
+
return invalid if invalid > 0
|
95
|
+
false
|
96
|
+
end
|
88
97
|
end
|
data/test/ita2_test.rb
CHANGED
@@ -31,5 +31,32 @@ class TestITA2 < Test::Unit::TestCase
|
|
31
31
|
def test_codes_skips_unkown_chars
|
32
32
|
assert_equal([1, 2, 1], "e\nüüe".to_ita2)
|
33
33
|
end
|
34
|
+
|
35
|
+
def test_punchcodes_case_insensitive
|
36
|
+
assert_equal(" # \n \n #\n# #\n# #", "OEm".to_punchcode)
|
37
|
+
end
|
34
38
|
|
35
|
-
|
39
|
+
def test_punchcodes
|
40
|
+
assert_equal(" # \n \n #\n# #\n# #", "oem".to_punchcode)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_punchcodes_with_nextline
|
44
|
+
assert_equal(" # ### # # \n ### # # #\n # # # \n# # # \n# # # # ", "oem\nwas\nhere\n".to_punchcode)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_codes_figs_ltrs_swaps
|
48
|
+
assert_equal( [27, 13, 13, 2, 25, 31, 12, 24, 2, 19, 3, 21], "!!\n?no\nway".to_ita2)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_invalid_letters
|
52
|
+
assert_equal(3, "@@@".invalid_letters?)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_invalid_letters_mixed_with_valid_ones
|
56
|
+
assert_equal(2, "hey!hey!@strange@sentence".invalid_letters?)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_invalid_letters_returns_false_if_valid_string
|
60
|
+
assert_equal(false, @text.invalid_letters?)
|
61
|
+
end
|
62
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- !binary |
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-03-
|
19
|
+
date: 2010-03-21 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|