Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.5.1-node-browsers
- image: circleci/ruby:2.7.3-node-browsers
- image: circleci/postgres:9.6.2-alpine
environment:
POSTGRES_USER: postgres
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Layout/CaseIndentation:
Layout/EndAlignment:
Enabled: false

Lint/HandleExceptions:
Lint/SuppressedException:
Enabled: false

Metrics/AbcSize:
Expand Down
71 changes: 39 additions & 32 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,51 +1,58 @@
PATH
remote: .
specs:
grantinee (0.3.3)
grantinee (0.4.0)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.0)
byebug (10.0.2)
diff-lcs (1.3)
method_source (0.9.0)
mysql2 (0.5.1)
parallel (1.12.1)
parser (2.5.1.0)
ast (~> 2.4.0)
pg (1.0.0)
powerpack (0.1.1)
rainbow (3.0.0)
ast (2.4.2)
byebug (11.1.3)
diff-lcs (1.5.0)
json (2.6.2)
method_source (1.0.0)
mysql2 (0.5.4)
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
pg (1.4.4)
rainbow (3.1.1)
rake (10.5.0)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
regexp_parser (2.6.0)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
rubocop (0.56.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.1)
rubocop (1.37.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 2.5)
powerpack (~> 0.1)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
unicode-display_width (1.4.0)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.23.0)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
unicode-display_width (2.3.0)

PLATFORMS
ruby
arm64-darwin-21

DEPENDENCIES
bundler (~> 1.16)
bundler (>= 1.3.0)
byebug
grantinee!
method_source
Expand All @@ -56,4 +63,4 @@ DEPENDENCIES
rubocop

BUNDLED WITH
1.16.2
2.3.24
2 changes: 1 addition & 1 deletion grantinee.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.16"
spec.add_development_dependency "bundler", ">= 1.3.0"
spec.add_development_dependency "byebug"
spec.add_development_dependency "method_source"
spec.add_development_dependency "rake", "~> 10.0"
Expand Down
9 changes: 4 additions & 5 deletions lib/grantinee/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

module Grantinee
class CLI
attr_accessor :options
attr_accessor :dsl
attr_accessor :engine
attr_accessor :options, :dsl, :engine

def initialize(args = ARGV, logger = ::Logger.new($stderr))
@args = args
Expand Down Expand Up @@ -118,8 +116,8 @@ def process_database_param
end

require options[:config]
rescue StandardError, LoadError => error
puts error
rescue StandardError, LoadError => e
puts e
exit
end

Expand All @@ -131,6 +129,7 @@ def process_grantinee_param
# Explicit verbose mode, overrides configuration value
def process_verbosity_param
return unless @options[:verbose]

log_levels = %w[debug info warn error fatal unknown]
@logger.level = log_levels.index(@options[:verbose])
end
Expand Down
6 changes: 1 addition & 5 deletions lib/grantinee/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ class Configuration
# Which engine is used by the library?
attr_accessor :engine

attr_accessor :logger
attr_accessor :logger, :password, :hostname, :port, :database

# Connection parameters
attr_accessor :username
attr_accessor :password
attr_accessor :hostname
attr_accessor :port
attr_accessor :database
attr_reader :url

# Allow verbose mode
Expand Down
4 changes: 2 additions & 2 deletions lib/grantinee/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def user(user, &block)
logger.debug "Got table: #{table}, fields: #{fields}"

@permissions << @data.merge(
kind: kind,
table: table,
kind: kind,
table: table,
fields: fields
)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/grantinee/engine/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def initialize
@connection = Mysql2::Client.new(
username: configuration.username,
password: configuration.password,
host: configuration.hostname,
port: configuration.port,
host: configuration.hostname,
port: configuration.port,
database: configuration.database
)
end
Expand Down
8 changes: 4 additions & 4 deletions lib/grantinee/engine/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ def initialize
configuration = Grantinee.configuration

@connection = PG::Connection.open(
user: configuration.username,
user: configuration.username,
password: configuration.password,
host: configuration.hostname,
port: configuration.port,
dbname: configuration.database
host: configuration.hostname,
port: configuration.port,
dbname: configuration.database
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/grantinee/engine/mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ module Engine
{
username: "privileged_person",
password: "secret",
host: "172.0.0.1",
port: 5432,
host: "172.0.0.1",
port: 5432,
database: "grantinee_test"
}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/grantinee/engine/postgresql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module Engine
{
user: "privileged_person",
password: "secret",
host: "172.0.0.1",
port: 5432,
host: "172.0.0.1",
port: 5432,
dbname: "grantinee_test"
}
end
Expand Down
13 changes: 6 additions & 7 deletions spec/support/mysql_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# frozen_string_literal: true

require "yaml"
Expand All @@ -11,16 +10,16 @@ def initialize(user: nil, password: nil, database: nil)
@client = Mysql2::Client.new(
username: user,
password: password,
host: Grantinee.configuration.hostname,
port: Grantinee.configuration.port,
host: Grantinee.configuration.hostname,
port: Grantinee.configuration.port,
database: database
)
end

def create_database(database)
@client.query "CREATE DATABASE #{database};"
rescue Mysql2::Error => error
puts error
rescue Mysql2::Error => e
puts e
end

def drop_database(database)
Expand Down Expand Up @@ -70,8 +69,8 @@ def drop_table(name)

def create_user_records
@client.query "INSERT INTO users (id, anonymized) VALUES ('1234', false);"
rescue StandardError => error
puts error
rescue StandardError => e
puts e
end

def close
Expand Down
9 changes: 4 additions & 5 deletions spec/support/postgresql_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# frozen_string_literal: true

require "yaml"
Expand All @@ -9,11 +8,11 @@ def initialize(user: nil, password: nil, database: nil)
load "./spec/fixtures/config_postgresql.rb"

@client = PG::Connection.open(
user: user,
user: user,
password: password,
host: Grantinee.configuration.hostname,
port: Grantinee.configuration.port,
dbname: database
host: Grantinee.configuration.hostname,
port: Grantinee.configuration.port,
dbname: database
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/support/shared_contexts/mysql_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
Mysql2::Client.new(
username: (defined?(user) ? user : users.first),
password: "secret",
host: Grantinee.configuration.hostname,
port: Grantinee.configuration.port,
host: Grantinee.configuration.hostname,
port: Grantinee.configuration.port,
database: Grantinee.configuration.database
)
end
Expand Down
8 changes: 4 additions & 4 deletions spec/support/shared_contexts/postgresql_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
load "./spec/fixtures/config_postgresql.rb"

PG::Connection.open(
user: (defined?(user) ? user : users.first),
user: (defined?(user) ? user : users.first),
password: "fake_password",
host: Grantinee.configuration.hostname,
port: Grantinee.configuration.port,
dbname: Grantinee.configuration.database
host: Grantinee.configuration.hostname,
port: Grantinee.configuration.port,
dbname: Grantinee.configuration.database
)
end

Expand Down