diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-06-15 16:31:13 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-06-15 16:31:13 -0400 |
commit | 1a435c0f4b41904025d0f263734cb9aea6a03b13 (patch) | |
tree | 96ce607542c806c4a99c0463c3fea534e4c8e424 /bin/common.rb | |
parent | 043466d94da837fefb95cda8ecab44b03049890d (diff) | |
parent | e4b972f3c82dbe4b5e363e48ed01d97cc060a2c0 (diff) |
Merge remote-tracking branch 'hackers/parabola-hackers'
# Conflicts:
# .gitignore
Diffstat (limited to 'bin/common.rb')
-rw-r--r-- | bin/common.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/common.rb b/bin/common.rb new file mode 100644 index 0000000..91e14be --- /dev/null +++ b/bin/common.rb @@ -0,0 +1,22 @@ +require 'yaml' + +def cfg + @cfg ||= YAML::load(open("parabola-hackers.yml")) +end + +def load_user_yaml(filename) + user = YAML::load(open(filename)) + groups = user["groups"] || [] + user["groups"] = groups.concat((groups & cfg["groupgroups"].keys).map{|g|cfg["groupgroups"][g]}.flatten) + return user +end + +def load_all_users + users = {} + Dir.glob("#{cfg["yamldir"]}/*.yml").map{|filename| + uid = File.basename(filename).sub(/^([0-9]*)\.yml$/, "\\1").to_i + user = load_user_yaml(filename) + users[uid] = user + } + return users +end |