Class: ASF::ICLA
- Inherits:
-
Object
- Object
- ASF::ICLA
- Defined in:
- lib/whimsy/asf/icla.rb
Constant Summary collapse
- OFFICERS =
ASF::SVN['private/foundation/officers']
- SOURCE =
OFFICERS ? "#{OFFICERS}/iclas.txt" : nil
- SUFFIXES =
/^([Jj][Rr]\.?|I{2,3}|I?V|VI{1,3}|[A-Z]\.)$/- @@mtime =
nil
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
Returns the value of attribute id.
-
#legal_name ⇒ Object
Returns the value of attribute legal_name.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.asciize(name) ⇒ Object
sort support.
-
.availids ⇒ Object
list of all ids.
-
.each(&block) ⇒ Object
iterate over all of the ICLAs.
-
.find_by_email(value) ⇒ Object
find ICLA by email.
-
.find_by_id(value) ⇒ Object
find ICLA by ID.
-
.find_by_name(value) ⇒ Object
find ICLA by name.
-
.lname(line) ⇒ Object
rearrange line in an order suitable for sorting.
-
.preload ⇒ Object
load ICLA information for every committer.
-
.refresh ⇒ Object
flush caches if source file changed.
-
.sort(source) ⇒ Object
sort an entire iclas.txt file.
- .svn_change ⇒ Object
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
4 5 6 |
# File 'lib/whimsy/asf/icla.rb', line 4 def email @email end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/whimsy/asf/icla.rb', line 4 def id @id end |
#legal_name ⇒ Object
Returns the value of attribute legal_name.
4 5 6 |
# File 'lib/whimsy/asf/icla.rb', line 4 def legal_name @legal_name end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/whimsy/asf/icla.rb', line 4 def name @name end |
Class Method Details
.asciize(name) ⇒ Object
sort support
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/whimsy/asf/icla.rb', line 110 def self.asciize(name) if name.match /[^\x00-\x7F]/ # digraphs. May be culturally sensitive name.gsub! /\u00df/, 'ss' name.gsub! /\u00e4|a\u0308/, 'ae' name.gsub! /\u00e5|a\u030a/, 'aa' name.gsub! /\u00e6/, 'ae' name.gsub! /\u00f1|n\u0303/, 'ny' name.gsub! /\u00f6|o\u0308/, 'oe' name.gsub! /\u00fc|u\u0308/, 'ue' # latin 1 name.gsub! /[\u00e0-\u00e5]/, 'a' name.gsub! /\u00e7/, 'c' name.gsub! /[\u00e8-\u00eb]/, 'e' name.gsub! /[\u00ec-\u00ef]/, 'i' name.gsub! /[\u00f2-\u00f6]|\u00f8/, 'o' name.gsub! /[\u00f9-\u00fc]/, 'u' name.gsub! /[\u00fd\u00ff]/, 'y' # Latin Extended-A name.gsub! /[\u0100-\u0105]/, 'a' name.gsub! /[\u0106-\u010d]/, 'c' name.gsub! /[\u010e-\u0111]/, 'd' name.gsub! /[\u0112-\u011b]/, 'e' name.gsub! /[\u011c-\u0123]/, 'g' name.gsub! /[\u0124-\u0127]/, 'h' name.gsub! /[\u0128-\u0131]/, 'i' name.gsub! /[\u0132-\u0133]/, 'ij' name.gsub! /[\u0134-\u0135]/, 'j' name.gsub! /[\u0136-\u0138]/, 'k' name.gsub! /[\u0139-\u0142]/, 'l' name.gsub! /[\u0143-\u014b]/, 'n' name.gsub! /[\u014C-\u0151]/, 'o' name.gsub! /[\u0152-\u0153]/, 'oe' name.gsub! /[\u0154-\u0159]/, 'r' name.gsub! /[\u015a-\u0162]/, 's' name.gsub! /[\u0162-\u0167]/, 't' name.gsub! /[\u0168-\u0173]/, 'u' name.gsub! /[\u0174-\u0175]/, 'w' name.gsub! /[\u0176-\u0178]/, 'y' name.gsub! /[\u0179-\u017e]/, 'z' # denormalized diacritics name.gsub! /[\u0300-\u036f]/, '' end name.strip.gsub /[^\w]+/, '-' end |
.availids ⇒ Object
list of all ids
78 79 80 81 82 83 84 85 |
# File 'lib/whimsy/asf/icla.rb', line 78 def self.availids return unless SOURCE refresh return @@availids if @@availids availids = [] each {|icla| availids << icla.id unless icla.id == 'notinavail'} @availids = availids end |
.each(&block) ⇒ Object
iterate over all of the ICLAs
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/whimsy/asf/icla.rb', line 88 def self.each(&block) refresh if @@id_index and not @@id_index.empty? @@id_index.values.each(&block) elsif @@email_index and not @@email_index.empty? @@email_index.values.each(&block) elsif @@name_index and not @@name_index.empty? @@name_index.values.each(&block) elsif SOURCE and File.exist?(SOURCE) File.read(SOURCE).scan(/^([-\w]+):(.*?):(.*?):(.*?):/).each do |list| icla = ICLA.new() icla.id = list[0] icla.legal_name = list[1] icla.name = list[2] icla.email = list[3] block.call(icla) end end end |
.find_by_email(value) ⇒ Object
find ICLA by email
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/whimsy/asf/icla.rb', line 53 def self.find_by_email(value) return unless SOURCE refresh unless @@email_index @@email_index = {} each {|icla| @@email_index[icla.email.downcase] = icla} end @@email_index[value.downcase] end |
.find_by_id(value) ⇒ Object
find ICLA by ID
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/whimsy/asf/icla.rb', line 40 def self.find_by_id(value) return if value == 'notinavail' or not SOURCE refresh unless @@id_index @@id_index = {} each {|icla| @@id_index[icla.id] = icla} end @@id_index[value] end |
.find_by_name(value) ⇒ Object
find ICLA by name
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/whimsy/asf/icla.rb', line 66 def self.find_by_name(value) return unless SOURCE refresh unless @@name_index @@name_index = {} each {|icla| @@name_index[icla.name] = icla} end @@email_index[value] end |
.lname(line) ⇒ Object
rearrange line in an order suitable for sorting
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/whimsy/asf/icla.rb', line 163 def self.lname(line) return '' if line.start_with? '#' id, name, rest = line.split(':',3) return '' unless name # Drop trailing (comment string) or /* comment */ name.sub! /\(.+\)$/,'' name.sub! /\/\*.+\*\/$/,'' return '' if name.strip.empty? name = name.split.reverse suffix = (name.shift if name.first =~ SUFFIXES) suffix += ' ' + name.shift if name.first =~ SUFFIXES name << name.shift name << name.shift if name.first=='Lewis' and name.last=='Ship' name << name.shift if name.first=='Gallardo' and name.last=='Rivera' name << name.shift if name.first=="S\u00e1nchez" and name.last=='Vega' # name << name.shift if name.first=='van' name.last.sub! /^IJ/, 'Ij' name.unshift(suffix) if suffix name.map! {|word| asciize(word)} name = name.reverse.join(' ') "#{name}:#{rest}" end |
.preload ⇒ Object
load ICLA information for every committer
33 34 35 36 37 |
# File 'lib/whimsy/asf/icla.rb', line 33 def self.preload each do |icla| ASF::Person.find(icla.id).icla = icla unless icla.id == 'notinaval' end end |
.refresh ⇒ Object
flush caches if source file changed
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/whimsy/asf/icla.rb', line 12 def self.refresh if not SOURCE or File.mtime(SOURCE) != @@mtime @@mtime = SOURCE ? File.mtime(SOURCE) : Time.now @@id_index = nil @@email_index = nil @@name_index = nil @@svn_change = nil @@availids = nil end end |
.sort(source) ⇒ Object
sort an entire iclas.txt file
190 191 192 193 194 195 196 |
# File 'lib/whimsy/asf/icla.rb', line 190 def self.sort(source) headers = source.scan(/^#.*/) lines = source.scan(/^\w.*/) headers.join("\n") + "\n" + lines.sort_by {|line| lname(line + "\n")}.join("\n") + "\n" end |
.svn_change ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/whimsy/asf/icla.rb', line 24 def self.svn_change self.refresh if SOURCE @@svn_change ||= Time.parse( `svn info #{SOURCE}`[/Last Changed Date: (.*) \(/, 1]).gmtime end end |