This repository has been archived by the owner on Dec 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use Enumerable.all?, s/chomp/strip/, handle nil case
- Loading branch information
Jesse Newland
committed
Dec 13, 2013
1 parent
93e18f8
commit 9cfc2cb
Showing
1 changed file
with
11 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,14 @@ def exists? | |
if lines.length > 1 | ||
current_grants = grants_for_db(@resource[:database], lines) | ||
|
||
if @resource[:grants].sort == current_grants.sort | ||
return false if current_grants.nil? | ||
return true if current_grants == ['ALL PRIVILEGES'] | ||
|
||
if Array(@resource[:grants]).all? { |g| current_grants.include?(g) } | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jnewland
Contributor
|
||
true | ||
else | ||
puts current_grants.inspect | ||
puts Array(@resource[:grants]).inspect | ||
false | ||
end | ||
else | ||
|
@@ -29,7 +34,11 @@ def exists? | |
|
||
def grants_for_db(db, arr) | ||
matching_grant = arr[1..-1].select { |line| line =~ / `#{db}`\.\* / }.first | ||
matching_grant.match(/^GRANT (.*) ON /)[1].split(",").map { |w| w.chomp } | ||
if matching_grant | ||
matching_grant.match(/^GRANT (.*) ON /)[1].split(",").map { |w| w.strip } | ||
else | ||
nil | ||
end | ||
end | ||
|
||
def grants | ||
|
Will this flatten as appropriate?