diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 34a04ca4..354f8a24 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: - {os: ubuntu-22.04, ruby: '3.0', db: mariadb10.6} - {os: ubuntu-20.04, ruby: '2.7', db: mariadb10.6} - {os: ubuntu-20.04, ruby: '2.7', db: mysql80} - - {os: ubuntu-18.04, ruby: '2.7', db: mysql57} + # - {os: ubuntu-18.04, ruby: '2.7', db: mysql57} # no longer exists # TODO - Windows CI # - {os: windows-2022, ruby: '3.2', db: mysql80} diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index eba2091d..02cfbae1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -45,7 +45,7 @@ Metrics/BlockNesting: # Offense count: 1 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 135 + Max: 141 # Offense count: 3 # Configuration parameters: IgnoredMethods. diff --git a/README.md b/README.md index cf35222d..d44e77dc 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ Ruby runtime and MySQL client libraries are compiled with the same OpenSSL family, 1.0 or 1.1 or 3.0, since only one can be loaded at runtime. ``` sh -$ brew install openssl@1.1 +$ brew install openssl@1.1 zstd $ gem install mysql2 -- --with-openssl-dir=$(brew --prefix openssl@1.1) or diff --git a/ci/setup.sh b/ci/setup.sh index 956608c6..938f0c8d 100644 --- a/ci/setup.sh +++ b/ci/setup.sh @@ -70,7 +70,7 @@ if [[ x$OSTYPE =~ ^xdarwin ]]; then done brew info "$DB" - brew install "$DB" + brew install "$DB" zstd DB_PREFIX="$(brew --prefix "${DB}")" export PATH="${DB_PREFIX}/bin:${PATH}" export LDFLAGS="-L${DB_PREFIX}/lib" diff --git a/ext/mysql2/extconf.rb b/ext/mysql2/extconf.rb index bee77585..01e5eeed 100644 --- a/ext/mysql2/extconf.rb +++ b/ext/mysql2/extconf.rb @@ -108,7 +108,7 @@ def add_ssl_defines(header) warn "-----\nUsing --with-mysql-dir=#{File.dirname inc}\n-----" rpath_dir = lib have_library('mysqlclient') -elsif (mc = (with_config('mysql-config') || Dir[GLOB].first)) +elsif (mc = with_config('mysql-config') || Dir[GLOB].first) # If the user has provided a --with-mysql-config argument, we must respect it or fail. # If the user gave --with-mysql-config with no argument means we should try to find it. mc = Dir[GLOB].first if mc == true diff --git a/lib/mysql2/client.rb b/lib/mysql2/client.rb index 582b6e30..f1013ea3 100644 --- a/lib/mysql2/client.rb +++ b/lib/mysql2/client.rb @@ -79,7 +79,7 @@ def initialize(opts = {}) end user = opts[:username] || opts[:user] - pass = opts[:password] || opts[:pass] + pass = extract_password(opts) host = opts[:host] || opts[:hostname] port = opts[:port] database = opts[:database] || opts[:dbname] || opts[:db] @@ -97,6 +97,15 @@ def initialize(opts = {}) connect user, pass, host, port, database, socket, flags, conn_attrs end + def extract_password(opts) + return opts[:password] || opts[:pass] unless opts[:password_provider] + + klass = Kernel.const_get(opts[:password_provider]) + + obj = klass.new(opts) + obj.password + end + def parse_ssl_mode(mode) m = mode.to_s.upcase if m.start_with?('SSL_MODE_') diff --git a/mysql2.gemspec b/mysql2.gemspec index cc9a55e4..28fd1c30 100644 --- a/mysql2.gemspec +++ b/mysql2.gemspec @@ -22,4 +22,6 @@ Mysql2::GEMSPEC = Gem::Specification.new do |s| s.files = `git ls-files README.md CHANGELOG.md LICENSE ext lib support`.split s.metadata['msys2_mingw_dependencies'] = 'libmariadbclient' + + s.add_dependency 'bigdecimal' end