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.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/gruber-case.rb +10 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTk5YzdmMzY4ZGYwY2YzY2U2YzMzMDIyMmZkZTcxOWFkMzUxYzk2ZA==
4
+ MWU5M2I0ZmNkNWQ4ZWU4ZTQ4MGEwZTU4ODRmOWQwNDA0M2RlMWE1OA==
5
5
  data.tar.gz: !binary |-
6
- ZDQyMDdiYmE4M2EwOTFkMGE4MDA1ZWQzZWEwZDcxZTAzMTBiZTQ4Nw==
6
+ ZmMwMmZlZTc4MTJmNDNiMWE1ZTRlOGJhOTNjOGFjYjBkZDAzZDUzNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTU0ZWUyMDI1M2M1MDVlOTI5MmRlYWE1ODJkZDBiMmExNzEzNzZhODhjYWE0
10
- ZmMwYzM1NzdmZTU5MjA4MDdkNzNlYzJmY2MyYWUwYjAzYjkyOGQ2YmI5OWMz
11
- Yjc2N2I2NGVhNmQzZDQ0ZmU4MGZiNTIwNmM2NDI4OTk5ZGIzZjA=
9
+ ZTkzNzAzMjQyYTU2NGZiODRmZmQzZDZjNWZmY2JjMzc2NzU5YTMzYjQ5NWY2
10
+ OGZjYWUyYjRhMGVkNWE2ZWRjODczYzY2YWE0MGNmZGUzZGRjZmQ5ZTc0OTZl
11
+ MzRjNThlOGYzYTVjZjE2MmFkZTYxNDgwYWEwMDIzZjQ5MzllMjU=
12
12
  data.tar.gz: !binary |-
13
- YTgyMzFmMGVmNzZmNWZlNDEwOTU0Yjc4ZDRjOWI1NjA2ZDI5M2E1OWY3MjA4
14
- NWJhYzdlOGVjNGVmZDA2NGVlNTdhNTJhMGExY2E4Yzk3NDMyMWUzOTMyYTRk
15
- YmYyMWE4YzQ5MTkzNjMzN2E4ZDA1MWY3NGQyZGZkNGZhY2VlZTY=
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
- # self-contained small words "at" and "a"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gruber-case
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Jackson