Created
June 4, 2009 16:25
-
-
Save ceritium/123694 to your computer and use it in GitHub Desktop.
Gitosis Config Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GitosisConfigGenerator | |
def initialize | |
@config = {} | |
end | |
def add_group(name, options = {}) | |
@config.store(name, {:writable => options[:writable], :readonly => options[:readonly], :members => options[:members]}) | |
end | |
def to_file(path) | |
File.open(path, "w") do |file| | |
file.puts "[gitosis]" | |
file.puts "\n" | |
@config.each_key do |key| | |
file.puts "[group #{key}]" | |
@config[key].each_pair do |key, value| | |
unless value.nil? | |
values = value.to_a.join(' ') | |
file.puts "#{key} = #{values}" | |
end | |
end | |
file.puts "\n" | |
end | |
end | |
end | |
end | |
# Example | |
# | |
# config = GitosisCofigGenerator.new | |
# config.add_group('babelhub', :members => ['deploy@flowersinspace', 'deploy@babelhub'], :writable => 'google') | |
# config.add_group('work-deploy', :members => ['deploy@mola_mazo'], :readonly => ['billgate', 'stallman']) | |
# config.to_file('exit.txt') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment