forked from emboss/krypt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide workaround for JRuby with native API access disabled. Prepare…
… release.
- Loading branch information
Showing
4 changed files
with
24 additions
and
6 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
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
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 |
---|---|---|
@@ -1,8 +1,26 @@ | ||
require_relative 'provider/provider' | ||
|
||
## | ||
# If JRuby is configured with native API access disabled, requiring the FFI | ||
# provider will result in a LoadError. The FFI provider is not required at | ||
# runtime as there is always a default (Java-based) provider. | ||
# | ||
|
||
def java? | ||
!! (RUBY_PLATFORM =~ /java/) | ||
end | ||
|
||
def native_disabled? | ||
require 'jruby' | ||
!JRuby.runtime.instance_config.native_enabled | ||
end | ||
|
||
begin | ||
require_relative 'provider/ffi' | ||
rescue LoadError => e | ||
# cf. https://github.com/krypt/krypt/issues/47 | ||
warn "FFI provider could not be loaded. Error message: #{e}" | ||
if java? && native_disabled? | ||
# Do not use the FFI provider with JRuby and native API access disabled | ||
else | ||
raise e | ||
end | ||
end |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Krypt | ||
VERSION = "0.0.2.rc1" | ||
VERSION = "0.0.2" | ||
end |