polskie_stringi 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. data/Rakefile +2 -1
  2. data/lib/polskie_stringi.rb +4 -1
  3. metadata +3 -3
data/Rakefile CHANGED
@@ -36,12 +36,13 @@ PKG_FILES = FileList[
36
36
 
37
37
  spec = Gem::Specification.new do |s|
38
38
  s.name = "polskie_stringi"
39
- s.version = "0.0.1"
39
+ s.version = "0.0.2"
40
40
  s.author = "v1x100r"
41
41
  s.email = "v1x100r@gmail.com"
42
42
  s.homepage = ""
43
43
  s.platform = Gem::Platform::RUBY
44
44
  s.summary = "Rozszerza funkcje klasy String o obsługę polskich znaków"
45
+ s.description = "Funkcje upcase, downcase, capitalize, upcase!, downcase!, capitalize! obsługują od teraz polskie znaki. Dodatkowo 2 nowe funkcje no_pl i no_pl! które czyszczą ogonki ze znaków, oraz metoda String.polish_chars pobierająca tablicę z polskimi literami."
45
46
  s.files = PKG_FILES.to_a
46
47
  s.require_path = "lib"
47
48
  s.has_rdoc = false
@@ -2,16 +2,19 @@
2
2
 
3
3
  class ::String
4
4
 
5
+ # zmień wszystkie litery na duże (łącznie z polskimi)
5
6
  def upcase
6
7
  # znajdź małe litery w łańcuchu, wyszukaj ich indeks w tablicy małych liter i podmień na wartość z tablicy dużych liter
7
8
  gsub(/[a-z#{String.polish_chars('small').join('')}]/) { |s| (('A'..'Z').to_a + String.polish_chars('big'))[(('a'..'z').to_a + String.polish_chars('small')).index(s)] }
8
9
  end
9
10
 
11
+ # zmień wszystkie litery na małe (łącznie z polskimi)
10
12
  def downcase
11
13
  # jak wyżej, ale odwrotnie
12
14
  gsub(/[A-Z#{String.polish_chars('big').join('')}]/) { |s| (('a'..'z').to_a + String.polish_chars('small'))[(('A'..'Z').to_a + String.polish_chars('big')).index(s)] }
13
15
  end
14
16
 
17
+ # usuń polskie ogonki (łącznie z polskimi)
15
18
  def no_pl
16
19
  # jak wyżej, ale tablicami są polskie znaki małe i duże, oraz ich odpowiedniki ASCII
17
20
  gsub(/[#{String.polish_chars.join('')}]/) { |s| %w[a e s c z z o l n A E S C Z Z O L N][String.polish_chars.index(s)] }
@@ -21,7 +24,7 @@ class ::String
21
24
  replace no_pl
22
25
  end
23
26
 
24
- # pierwsza litera upcase, reszta downcase
27
+ # pierwsza litera duża, reszta mała
25
28
  def capitalize
26
29
  self[0].to_s.upcase + self[1..size].to_s.downcase
27
30
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - v1x100r
@@ -18,7 +18,7 @@ date: 2011-02-18 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
- description:
21
+ description: "Funkcje upcase, downcase, capitalize, upcase!, downcase!, capitalize! obs\xC5\x82uguj\xC4\x85 od teraz polskie znaki. Dodatkowo 2 nowe funkcje no_pl i no_pl! kt\xC3\xB3re czyszcz\xC4\x85 ogonki ze znak\xC3\xB3w, oraz metoda String.polish_chars pobieraj\xC4\x85ca tablic\xC4\x99 z polskimi literami."
22
22
  email: v1x100r@gmail.com
23
23
  executables: []
24
24