From 57997055a817d2104f605a56141ae26515aabbd2 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 3 Feb 2015 08:43:02 +0000 Subject: [PATCH] Fix argument order for each_with_object --- cookbooks/mysql/libraries/mysql.rb | 8 ++++---- cookbooks/postgresql/libraries/postgresql.rb | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cookbooks/mysql/libraries/mysql.rb b/cookbooks/mysql/libraries/mysql.rb index 9ddc238c7..2b2bca67d 100644 --- a/cookbooks/mysql/libraries/mysql.rb +++ b/cookbooks/mysql/libraries/mysql.rb @@ -87,17 +87,17 @@ class Chef end def users - @users ||= query("SELECT * FROM user").each_with_object({}) do |users, user| + @users ||= query("SELECT * FROM user").each_with_object({}) do |user, users| name = "'#{user[:user]}'@'#{user[:host]}'" - users[name] = USER_PRIVILEGES.each_with_object({}) do |privileges, privilege| + users[name] = USER_PRIVILEGES.each_with_object({}) do |privilege, privileges| privileges[privilege] = user["#{privilege}_priv".to_sym] == "Y" end end end def databases - @databases ||= query("SHOW databases").each_with_object({}) do |databases, database| + @databases ||= query("SHOW databases").each_with_object({}) do |database, databases| databases[database[:database]] = { :permissions => {} } @@ -107,7 +107,7 @@ class Chef if database = @databases[record[:db]] user = "'#{record[:user]}'@'#{record[:host]}'" - database[:permissions][user] = DATABASE_PRIVILEGES.each_with_object([]) do |privileges, privilege| + database[:permissions][user] = DATABASE_PRIVILEGES.each_with_object([]) do |privilege, privileges| privileges << privilege if record["#{privilege}_priv".to_sym] == "Y" end end diff --git a/cookbooks/postgresql/libraries/postgresql.rb b/cookbooks/postgresql/libraries/postgresql.rb index c12174753..05bf158f2 100644 --- a/cookbooks/postgresql/libraries/postgresql.rb +++ b/cookbooks/postgresql/libraries/postgresql.rb @@ -63,7 +63,7 @@ class Chef end def users - @users ||= query("SELECT * FROM pg_user").each_with_oject({}) do |users, user| + @users ||= query("SELECT * FROM pg_user").each_with_object({}) do |user, users| users[user[:usename]] = { :superuser => user[:usesuper] == "t", :createdb => user[:usercreatedb] == "t", @@ -74,7 +74,7 @@ class Chef end def databases - @databases ||= query("SELECT d.datname, u.usename, d.encoding, d.datcollate, d.datctype FROM pg_database AS d INNER JOIN pg_user AS u ON d.datdba = u.usesysid").each_with_object({}) do |databases, database| + @databases ||= query("SELECT d.datname, u.usename, d.encoding, d.datcollate, d.datctype FROM pg_database AS d INNER JOIN pg_user AS u ON d.datdba = u.usesysid").each_with_object({}) do |database, databases| databases[database[:datname]] = { :owner => database[:usename], :encoding => database[:encoding], @@ -86,7 +86,7 @@ class Chef def extensions(database) @extensions ||= {} - @extensions[database] ||= query("SELECT extname, extversion FROM pg_extension", :database => database).each_with_object({}) do |extensions, extension| + @extensions[database] ||= query("SELECT extname, extversion FROM pg_extension", :database => database).each_with_object({}) do |extension, extensions| extensions[extension[:extname]] = { :version => extension[:extversion] } @@ -95,7 +95,7 @@ class Chef def tables(database) @tables ||= {} - @tables[database] ||= query("SELECT n.nspname, c.relname, u.usename, c.relacl FROM pg_class AS c INNER JOIN pg_user AS u ON c.relowner = u.usesysid INNER JOIN pg_namespace AS n ON c.relnamespace = n.oid", :database => database).each_with_object({}) do |tables, table| + @tables[database] ||= query("SELECT n.nspname, c.relname, u.usename, c.relacl FROM pg_class AS c INNER JOIN pg_user AS u ON c.relowner = u.usesysid INNER JOIN pg_namespace AS n ON c.relnamespace = n.oid", :database => database).each_with_object({}) do |table, tables| name = "#{table[:nspname]}.#{table[:relname]}" tables[name] = { @@ -108,7 +108,7 @@ class Chef private def parse_acl(acl) - acl.sub(/^\{(.*)\}$/, "\\1").split(",").each_with_object({}) do |permissions, entry| + acl.sub(/^\{(.*)\}$/, "\\1").split(",").each_with_object({}) do |entry, permissions| entry = entry.sub(/^"(.*)"$/) { Regexp.last_match[1].gsub(/\\"/, '"') }.sub(/\/.*$/, "") user, privileges = entry.split("=") -- 2.39.5