string_case_pl 0.0.2 → 0.0.3

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.
@@ -37,6 +37,17 @@ class String
37
37
  end
38
38
  self.old_upcase_wo_pl
39
39
  end
40
+
41
+ def capitalize
42
+ self[0] = case self.encoding.name
43
+ when "UTF-8"
44
+ self[0].tr(PL_UTF_8_LOWER, PL_UTF_8_UPPER)
45
+ when "ISO-8859-2"
46
+ self[0].tr(PL_ISO_8859_2_LOWER, PL_ISO_8859_2_UPPER)
47
+ when "Windows-1250"
48
+ self[0].tr(PL_WINDOWS_1250_LOWER, PL_WINDOWS_1250_UPPER)
49
+ end
50
+ self
51
+ end
40
52
 
41
53
  end
42
-
@@ -1,11 +1,11 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "string_case_pl"
3
- s.version = "0.0.2"
3
+ s.version = "0.0.3"
4
4
  s.date = "2009-12-27"
5
5
  s.summary = "Additional support for Polish encodings in Ruby 1.9"
6
6
  s.email = "apohllo@o2.pl"
7
7
  s.homepage = "http://apohllo.pl/blog"
8
- s.description = "Polish extensions for Ruby 1.9 String #upcase and #downcase supporting polish diacritics"
8
+ s.description = "Polish extensions for Ruby 1.9 String #upcase, #downcase and #capitalize supporting polish diacritics"
9
9
  s.require_path = "lib"
10
10
  s.has_rdoc = false
11
11
  s.authors = ['Aleksander Pohl']
@@ -10,6 +10,9 @@ class TestCharacterCaseChange < Test::Unit::TestCase
10
10
  @iso_upper = "\xa1\xc6\xca\xa3\xd1\xd3\xa6\xaf\xacABCDEFGHIJKLMNOPQRSTUVWXYZ".force_encoding("ISO-8859-2")
11
11
  @windows_lower = "\xb9\xe6\xea\xb3\xf1\xf3\x9c\xbf\x9fabcdefghijklmnopqrstuvwxyz".force_encoding("Windows-1250")
12
12
  @windows_upper = "\xa5\xc6\xca\xa3\xd1\xd3\x8c\xaf\x8fABCDEFGHIJKLMNOPQRSTUVWXYZ".force_encoding("Windows-1250")
13
+ @utf_capitalized = "Ąćęłńóśżźabcdefghijklmnopqrstuvwxyz".force_encoding("UTF-8")
14
+ @iso_capitalized = "\xa1\xe6\xea\xb3\xf1\xf3\xb6\xbf\xbcabcdefghijklmnopqrstuvwxyz".force_encoding("ISO-8859-2")
15
+ @windows_capitalized = "\xa5\xe6\xea\xb3\xf1\xf3\x9c\xbf\x9fabcdefghijklmnopqrstuvwxyz".force_encoding("Windows-1250")
13
16
  end
14
17
 
15
18
  def test_utf_8_downcase
@@ -35,5 +38,17 @@ class TestCharacterCaseChange < Test::Unit::TestCase
35
38
  def test_windows_1250_upcase
36
39
  assert_equal(@windows_upper, @windows_lower.upcase)
37
40
  end
41
+
42
+ def test_utf_8_capitalize
43
+ assert_equal(@utf_capitalized, @utf_lower.capitalize)
44
+ end
45
+
46
+ def test_windows_1250_capitalize
47
+ assert_equal(@windows_capitalized, @windows_lower.capitalize)
48
+ end
49
+
50
+ def test_iso_8859_2_capitalize
51
+ assert_equal(@iso_capitalized, @iso_lower.capitalize)
52
+ end
53
+
38
54
  end
39
-
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aleksander Pohl
@@ -18,7 +18,7 @@ date: 2009-12-27 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
- description: "Polish extensions for Ruby 1.9 String #upcase and #downcase supporting polish diacritics"
21
+ description: "Polish extensions for Ruby 1.9 String #upcase, #downcase and #capitalize supporting polish diacritics"
22
22
  email: apohllo@o2.pl
23
23
  executables: []
24
24