X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/faf8ae12e85eabb050b0f5eceb2cb67ad1de5261..57997055a817d2104f605a56141ae26515aabbd2:/cookbooks/mysql/libraries/mysql.rb diff --git a/cookbooks/mysql/libraries/mysql.rb b/cookbooks/mysql/libraries/mysql.rb index c0da28f33..2b2bca67d 100644 --- a/cookbooks/mysql/libraries/mysql.rb +++ b/cookbooks/mysql/libraries/mysql.rb @@ -87,33 +87,28 @@ class Chef end def users - @users ||= query("SELECT * FROM user").inject({}) do |users,user| + @users ||= query("SELECT * FROM user").each_with_object({}) do |user, users| name = "'#{user[:user]}'@'#{user[:host]}'" - users[name] = USER_PRIVILEGES.inject({}) do |privileges,privilege| + users[name] = USER_PRIVILEGES.each_with_object({}) do |privilege, privileges| privileges[privilege] = user["#{privilege}_priv".to_sym] == "Y" - privileges end - - users end end def databases - @databases ||= query("SHOW databases").inject({}) do |databases,database| + @databases ||= query("SHOW databases").each_with_object({}) do |database, databases| databases[database[:database]] = { :permissions => {} } - databases end query("SELECT * FROM db").each do |record| if database = @databases[record[:db]] user = "'#{record[:user]}'@'#{record[:host]}'" - database[:permissions][user] = DATABASE_PRIVILEGES.inject([]) do |privileges,privilege| + database[:permissions][user] = DATABASE_PRIVILEGES.each_with_object([]) do |privilege, privileges| privileges << privilege if record["#{privilege}_priv".to_sym] == "Y" - privileges end end end