diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-06-15 13:03:50 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-06-15 13:03:50 -0400 |
commit | 61fc766d07e5252b9618c6548ea714649ab54a54 (patch) | |
tree | 38b7b8bd1057269ca40f2e63d570abbe3864ca02 /bin/common.rb | |
parent | 30b47ce9573dde234210ea9e0d1606ee5104b96e (diff) |
Pull tool configuration into a hackers-git.yml
Diffstat (limited to 'bin/common.rb')
-rw-r--r-- | bin/common.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/common.rb b/bin/common.rb new file mode 100644 index 0000000..a5840ec --- /dev/null +++ b/bin/common.rb @@ -0,0 +1,16 @@ +require 'yaml' + +def cfg + @cfg ||= YAML::load(open("hackers-git.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 + Dir.glob("#{cfg["yamldir"]}/*.yml").map{|filename|load_user_yaml(filename)} +end |