Module: ASF
- Defined in:
- lib/whimsy/asf/person.rb,
lib/whimsy/asf.rb,
lib/whimsy/asf/git.rb,
lib/whimsy/asf/svn.rb,
lib/whimsy/asf/auth.rb,
lib/whimsy/asf/icla.rb,
lib/whimsy/asf/ldap.rb,
lib/whimsy/asf/ldap.rb,
lib/whimsy/asf/mail.rb,
lib/whimsy/asf/rack.rb,
lib/whimsy/asf/site.rb,
lib/whimsy/asf/watch.rb,
lib/whimsy/asf/agenda.rb,
lib/whimsy/asf/config.rb,
lib/whimsy/asf/member.rb,
lib/whimsy/asf/nominees.rb,
lib/whimsy/asf/podlings.rb,
lib/whimsy/asf/committee.rb
Overview
support for sorting of names
Defined Under Namespace
Modules: Auth, Board, LDAP Classes: Authorization, AutoGC, Base, Committee, Config, Git, Group, HTTPS_workarounds, ICLA, LazyHash, Mail, Member, Person, Podling, SVN, Service, Site
Constant Summary collapse
- ETCLDAP =
'/etc/ldap'
- Podlings =
more backwards compatibility
Podling
Class Method Summary collapse
- .committers ⇒ Object
-
.dereference_weakref(object, attr, &block) ⇒ Object
safely dereference a weakref array attribute.
-
.init_ldap(reset = false) ⇒ Object
public entry point for establishing a connection safely.
-
.ldap ⇒ Object
Note: FreeBSD seems to use /usr/local/etc/openldap/ldap.conf.
- .library_gitinfo ⇒ Object
- .library_mtime ⇒ Object
- .members ⇒ Object
- .pmc_chairs ⇒ Object
-
.search_archive_by_id(id) ⇒ Object
Search archive for historical records of people who were committers but never submitted an ICLA (some of which are still ASF members or members of a PMC).
-
.search_one(base, filter, attrs = nil) ⇒ Object
search with a scope of one, with automatic retry/failover.
- .weakref(attr, &block) ⇒ Object
Class Method Details
.committers ⇒ Object
316 317 318 |
# File 'lib/whimsy/asf/ldap.rb', line 316 def self.committers weakref(:committers) {Group.find('committers').members} end |
.dereference_weakref(object, attr, &block) ⇒ Object
safely dereference a weakref array attribute. Block provided is used when reference is not set or has been reclaimed.
294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/whimsy/asf/ldap.rb', line 294 def self.dereference_weakref(object, attr, &block) attr = "@#{attr}" value = object.instance_variable_get(attr) || block.call value[0..-1] rescue WeakRef::RefError value = block.call ensure if not value or RUBY_VERSION.start_with? '1' object.instance_variable_set(attr, value) elsif value and not value.instance_of? WeakRef object.instance_variable_set(attr, WeakRef.new(value)) end end |
.init_ldap(reset = false) ⇒ Object
public entry point for establishing a connection safely
237 238 239 240 241 242 |
# File 'lib/whimsy/asf/ldap.rb', line 237 def self.init_ldap(reset = false) ASF::LDAP::CONNECT_LOCK.synchronize do @ldap = nil if reset @ldap ||= ASF::LDAP.connect(!reset) end end |
.ldap ⇒ Object
Note: FreeBSD seems to use /usr/local/etc/openldap/ldap.conf
253 254 255 |
# File 'lib/whimsy/asf/ldap.rb', line 253 def self.ldap @ldap || self.init_ldap end |
.library_gitinfo ⇒ Object
24 25 26 27 |
# File 'lib/whimsy/asf.rb', line 24 def self.library_gitinfo return @info if @info @info = `git show --format="%h %ci" -s HEAD`.strip end |
.library_mtime ⇒ Object
17 18 19 20 21 22 |
# File 'lib/whimsy/asf.rb', line 17 def self.library_mtime parent_dir = File.dirname(File.(__FILE__)) sources = Dir.glob("#{parent_dir}/**/*") times = sources.map {|source| File.mtime(source)} times.max.gmtime end |
.members ⇒ Object
320 321 322 |
# File 'lib/whimsy/asf/ldap.rb', line 320 def self.members weakref(:members) {Group.find('member').members} end |
.pmc_chairs ⇒ Object
312 313 314 |
# File 'lib/whimsy/asf/ldap.rb', line 312 def self.pmc_chairs weakref(:pmc_chairs) {Service.find('pmc-chairs').members} end |
.search_archive_by_id(id) ⇒ Object
Search archive for historical records of people who were committers but never submitted an ICLA (some of which are still ASF members or members of a PMC).
168 169 170 171 172 173 |
# File 'lib/whimsy/asf/icla.rb', line 168 def self.search_archive_by_id(id) archive = ASF::SVN['private/foundation/officers/historic'] name = JSON.parse(File.read("#{archive}/committers.json"))[id] name = id if name and name.empty? name end |
.search_one(base, filter, attrs = nil) ⇒ Object
search with a scope of one, with automatic retry/failover
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/whimsy/asf/ldap.rb', line 258 def self.search_one(base, filter, attrs=nil) cmd = "ldapsearch -x -LLL -b #{base} -s one #{filter} " + "#{[attrs].flatten.join(' ')}" # try once per host, with a minimum of two tries attempts_left = [ASF::LDAP.hosts.length, 2].max begin attempts_left -= 1 init_ldap unless @ldap return [] unless @ldap target = @ldap.get_option(::LDAP::LDAP_OPT_HOST_NAME) rescue '?' Wunderbar.info "[#{target}] #{cmd}" result = @ldap.search2(base, ::LDAP::LDAP_SCOPE_ONELEVEL, filter, attrs) rescue Exception => re if attempts_left <= 0 Wunderbar.error "[#{target}] => #{re.inspect} for #{cmd}" raise else Wunderbar.warn "[#{target}] => #{re.inspect} for #{cmd}, retrying ..." @ldap.unbind if @ldap.bound? rescue nil @ldap = nil # force new connection sleep 1 retry end end result.map! {|hash| hash[attrs]} if String === attrs result.compact end |
.weakref(attr, &block) ⇒ Object
308 309 310 |
# File 'lib/whimsy/asf/ldap.rb', line 308 def self.weakref(attr, &block) self.dereference_weakref(self, attr, &block) end |