whimsy-asf 0.0.45 → 0.0.46

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/asf.version +1 -1
  3. data/lib/whimsy/asf/icla.rb +88 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 948fb1720e0455ab4e03aa1438cb1462f421eefa
4
- data.tar.gz: 1dbe613d75215a1bfbe5bb8d4e7d9d2386c30972
3
+ metadata.gz: 1bc6997362bf3158089292cac392c1739f19518a
4
+ data.tar.gz: cb4e2622ea38148c6621d3f37cf6b9bac45d3457
5
5
  SHA512:
6
- metadata.gz: cd7c5045787dd2d85d37c5a5bca82489061ef311d4b07313b801aa2363ea57279c9229986d804bd8e3170bc214546edb60ff3db7e8d8756ea095d41bf95d2814
7
- data.tar.gz: 50c75640fa5a36d3a46af96e78855bba0c6962ce7f15f3701b05081a6218ca2114fdafdbe684c0b08395090329086e66e2c792700bd5bb95c21d085552d35d78
6
+ metadata.gz: e8cf182dc4f990db6aec7a24612f6ad73a6062e6d985cf7689459d99a36710b4b168bc6e02ff27eb757eea17492cf4f9c0efa49fe56d5fc4fc896edbe5694e70
7
+ data.tar.gz: f6d32065c6acd7e25b02abddf5ff3650071c67a0f55852870f89935973cf843dbdaafaef1f30432f165a02deb4aae145e0aa908e774eee8d3d669364e59eac95
data/asf.version CHANGED
@@ -1 +1 @@
1
- 0.0.45
1
+ 0.0.46
@@ -49,6 +49,94 @@ module ASF
49
49
  iclas.scan(/^([-\w]+):(.*?):(.*?):(.*?):/).each(&block)
50
50
  end
51
51
  end
52
+
53
+ # sort support
54
+
55
+ def self.asciize(name)
56
+ if name.match /[^\x00-\x7F]/
57
+ # digraphs. May be culturally sensitive
58
+ name.gsub! /\u00df/, 'ss'
59
+ name.gsub! /\u00e4|a\u0308/, 'ae'
60
+ name.gsub! /\u00e5|a\u030a/, 'aa'
61
+ name.gsub! /\u00e6/, 'ae'
62
+ name.gsub! /\u00f1|n\u0303/, 'ny'
63
+ name.gsub! /\u00f6|o\u0308/, 'oe'
64
+ name.gsub! /\u00fc|u\u0308/, 'ue'
65
+
66
+ # latin 1
67
+ name.gsub! /[\u00e0-\u00e5]/, 'a'
68
+ name.gsub! /\u00e7/, 'c'
69
+ name.gsub! /[\u00e8-\u00eb]/, 'e'
70
+ name.gsub! /[\u00ec-\u00ef]/, 'i'
71
+ name.gsub! /[\u00f2-\u00f6]|\u00f8/, 'o'
72
+ name.gsub! /[\u00f9-\u00fc]/, 'u'
73
+ name.gsub! /[\u00fd\u00ff]/, 'y'
74
+
75
+ # Latin Extended-A
76
+ name.gsub! /[\u0100-\u0105]/, 'a'
77
+ name.gsub! /[\u0106-\u010d]/, 'c'
78
+ name.gsub! /[\u010e-\u0111]/, 'd'
79
+ name.gsub! /[\u0112-\u011b]/, 'e'
80
+ name.gsub! /[\u011c-\u0123]/, 'g'
81
+ name.gsub! /[\u0124-\u0127]/, 'h'
82
+ name.gsub! /[\u0128-\u0131]/, 'i'
83
+ name.gsub! /[\u0132-\u0133]/, 'ij'
84
+ name.gsub! /[\u0134-\u0135]/, 'j'
85
+ name.gsub! /[\u0136-\u0138]/, 'k'
86
+ name.gsub! /[\u0139-\u0142]/, 'l'
87
+ name.gsub! /[\u0143-\u014b]/, 'n'
88
+ name.gsub! /[\u014C-\u0151]/, 'o'
89
+ name.gsub! /[\u0152-\u0153]/, 'oe'
90
+ name.gsub! /[\u0154-\u0159]/, 'r'
91
+ name.gsub! /[\u015a-\u0162]/, 's'
92
+ name.gsub! /[\u0162-\u0167]/, 't'
93
+ name.gsub! /[\u0168-\u0173]/, 'u'
94
+ name.gsub! /[\u0174-\u0175]/, 'w'
95
+ name.gsub! /[\u0176-\u0178]/, 'y'
96
+ name.gsub! /[\u0179-\u017e]/, 'z'
97
+
98
+ # denormalized diacritics
99
+ name.gsub! /[\u0300-\u036f]/, ''
100
+ end
101
+
102
+ name.gsub /[^\w]+/, '-'
103
+ end
104
+
105
+ SUFFIXES = /^([Jj][Rr]\.?|I{2,3}|I?V|VI{1,3}|[A-Z]\.)$/
106
+
107
+ # rearrange line in an order suitable for sorting
108
+ def self.lname(line)
109
+ return '' unless line =~ /^\w.*?:(.*?)(:(.*?):(.*?)(:(.*))?)\n?/
110
+ name, rest = $1, $2
111
+
112
+ # Drop trailing (comment string) or /* comment */
113
+ name.sub! /\(.+\)$/,''
114
+ name.sub! /\/\*.+\*\/$/,''
115
+
116
+ name = name.split.reverse
117
+ suffix = (name.shift if name.first =~ SUFFIXES)
118
+ suffix += ' ' + name.shift if name.first =~ SUFFIXES
119
+ name << name.shift
120
+ name << name.shift if name.first=='Lewis' and name.last=='Ship'
121
+ name << name.shift if name.first=='Gallardo' and name.last=='Rivera'
122
+ name << name.shift if name.first=="S\u00e1nchez" and name.last=='Vega'
123
+ # name << name.shift if name.first=='van'
124
+ name.last.sub! /^IJ/, 'Ij'
125
+ name.unshift(suffix) if suffix
126
+ name.map! {|word| asciize(word)}
127
+ name = name.reverse.join(' ')
128
+
129
+ name + rest
130
+ end
131
+
132
+ # sort an entire iclas.txt file
133
+ def self.sort(source)
134
+ headers = source.scan(/^#.*/)
135
+ lines = source.scan(/^\w.*/)
136
+
137
+ headers.join("\n") + "\n" +
138
+ lines.sort_by {|line| lname(line + "\n")}.join("\n") + "\n"
139
+ end
52
140
  end
53
141
 
54
142
  class Person
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whimsy-asf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.45
4
+ version: 0.0.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-02 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri