Class: ASF::Authorization
- Inherits:
-
Object
- Object
- ASF::Authorization
- Includes:
- Enumerable
- Defined in:
- lib/whimsy/asf/auth.rb
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(file = 'asf') ⇒ Authorization
constructor
A new instance of Authorization.
-
#to_h ⇒ Object
backwards compatibility for Ruby versions <= 2.0.
Constructor Details
#initialize(file = 'asf') ⇒ Authorization
Returns a new instance of Authorization.
10 11 12 |
# File 'lib/whimsy/asf/auth.rb', line 10 def initialize(file='asf') @file = file end |
Class Method Details
.find_by_id(value) ⇒ Object
6 7 8 |
# File 'lib/whimsy/asf/auth.rb', line 6 def self.find_by_id(value) new.select {|auth, ids| ids.include? value}.map(&:first) end |
Instance Method Details
#each ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/whimsy/asf/auth.rb', line 14 def each # TODO - should this read the Git repo directly? auth = ASF::Git.find('infrastructure-puppet') if auth auth += '/modules/subversion_server/files/authorization' else # SVN copy is no longer in use - see INFRA-11452 raise Exception.new("Cannot find Git: infrastructure-puppet") end File.read("#{auth}/#{@file}-authorization-template"). scan(/^([-\w]+)=(\w.*)$/).each do |pmc, ids| yield pmc, ids.split(',') end end |
#to_h ⇒ Object
backwards compatibility for Ruby versions <= 2.0
32 33 34 |
# File 'lib/whimsy/asf/auth.rb', line 32 def to_h Hash[self.to_a] end |