gruber-case 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/gruber-case.rb +10 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWU5M2I0ZmNkNWQ4ZWU4ZTQ4MGEwZTU4ODRmOWQwNDA0M2RlMWE1OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmMwMmZlZTc4MTJmNDNiMWE1ZTRlOGJhOTNjOGFjYjBkZDAzZDUzNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTkzNzAzMjQyYTU2NGZiODRmZmQzZDZjNWZmY2JjMzc2NzU5YTMzYjQ5NWY2
|
10
|
+
OGZjYWUyYjRhMGVkNWE2ZWRjODczYzY2YWE0MGNmZGUzZGRjZmQ5ZTc0OTZl
|
11
|
+
MzRjNThlOGYzYTVjZjE2MmFkZTYxNDgwYWEwMDIzZjQ5MzllMjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGE0MGM1MGUzNTllMTAxMzgwZmE1OTg2MDVkYTI2M2FkMmZmYjBmZTlmNTkz
|
14
|
+
NzRiZDkzZDRjNDViYTlhZjU5ZGViYzM1YzZlMGUxNmIzNjg4N2M3ZTgxYzE0
|
15
|
+
OTgyNmEwOGNmYjJmMjMwZjFhNTZiOTEwNmIzNGIxZTIyNTEyNmU=
|
data/lib/gruber-case.rb
CHANGED
@@ -6,7 +6,6 @@ class String
|
|
6
6
|
small_words = %w( a an and as at but by en for if in of on or the to v[.]? via vs[.]? )
|
7
7
|
small_re = small_words.join('|')
|
8
8
|
|
9
|
-
|
10
9
|
line = ""
|
11
10
|
self.split(/( [:.;?!][ ] | (?:[ ]|^)["“] )/x).each do |s|
|
12
11
|
|
@@ -33,8 +32,17 @@ class String
|
|
33
32
|
line.gsub!(/ V(s?)\. /, ' v\1. ') # "v." and "vs."
|
34
33
|
line.gsub!(/(['’])S\b/, '\1s') # 'S (otherwise you get "the SEC'S decision")
|
35
34
|
line.gsub!(/\b(AT&T|Q&A)\b/i) { |w| w.upcase } # "AT&T" and "Q&A", which get tripped up by
|
36
|
-
|
35
|
+
# self-contained small words "at" and "a"
|
37
36
|
|
38
37
|
line
|
39
38
|
end
|
39
|
+
|
40
|
+
def namecase
|
41
|
+
small_words = ["'s", "'t", "aan", "aan 't", "aan de", "aan den", "aan der", "aan het", "al", "auf", "aus", "bij", "bij 't", "bij de", "bij den", "bij het", "boven d'", "d'", "da[s]?", "dalla", "de", "de die", "de die le", "de l'", "de la", "de las", "de le", "de van der", "del", "della", "den", "der", "des", "di", "do[s]?", "el", "het", "in", "in 't", "in de", "in den", "in der", "in het", "onder", "onder 't", "onder de", "onder den", "onder het", "op", "op 't", "op de", "op den", "op der", "op gen", "op het", "op ten", "over", "over 't", "over de", "over den", "over het", "saint", "st", "ste", "te", "ten", "ter", "tot", "uijt", "uijt 't", "uijt de", "uijt den", "uijt het", "uijt te de", "uijt ten", "uit", "uit 't", "uit de", "uit den", "uit het", "uit te de", "uit ten", "van", "van 't", "van de", "van de l'", "van den", "van der", "van gen", "van het", "van la", "van ter", "van van de", "vander", "ver", "von", "voor", "voor de", "voor den", "voor in 't"]
|
42
|
+
small_re = small_words.join('|')
|
43
|
+
s = self.split(" ").map(&:capitalize).join(" ")
|
44
|
+
s.gsub!(/'\w/io) { |w| w.upcase }
|
45
|
+
s.gsub!(/\b(#{small_re})\b/io) { |w| w.downcase }
|
46
|
+
s
|
47
|
+
end
|
40
48
|
end
|