Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tombruijn/jruby-env-tester
This is an jRuby example app using an extension, showing that environment variables in jRuby are not cleared using ENV.delete("FOO"), ENV["FOO"] = nil, etc. when fetched in an extension.
https://github.com/tombruijn/jruby-env-tester
Last synced: 13 days ago
JSON representation
This is an jRuby example app using an extension, showing that environment variables in jRuby are not cleared using ENV.delete("FOO"), ENV["FOO"] = nil, etc. when fetched in an extension.
- Host: GitHub
- URL: https://github.com/tombruijn/jruby-env-tester
- Owner: tombruijn
- Created: 2017-12-07T16:41:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-07T17:06:24.000Z (about 7 years ago)
- Last Synced: 2024-12-12T23:07:56.205Z (19 days ago)
- Language: Ruby
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jRuby env tester
This is an jRuby example app using an extension, showing that environment
variables in jRuby are not cleared using `ENV.delete("FOO")`, `ENV["FOO"] =
nil`, etc. when fetched in an extension.New values on an environment variable are synced, but it doesn't sync any
assignments to `nil` or `delete` calls.The value unset changes on the ENV constant only work in the Ruby runtime and
not in any extension.This is behavior differs from MRI.
## Requirements
- Rust installed
- Ruby MRI 2.3.5 installed
- jRuby 9.1.14.0 installed## How to run
### MRI
```
(cd lib && cargo build --release)
chruby ruby-2.3.5 # or your Ruby version manager of choice
bundle installbundle exec ruby app.rb
```### jRuby
```
(cd lib && cargo build --release)
chruby jruby-9.1.14.0 # or your Ruby version manager of choice
bundle installbundle exec ruby app.rb
```## Test output
### MRI output
```
TEST: ENV["FOO"] = "something"
Ruby result: FOO = "something"
Extension result: FOO = "something"TEST: ENV.delete("FOO")
Ruby result: FOO is not set
Extension result: FOO is not setTEST: ENV["FOO"] = nil
Ruby result: FOO is not set
Extension result: FOO is not setTEST: ENV.update("FOO" => nil)
Ruby result: FOO is not set
Extension result: FOO is not setTEST: ENV.clear && ENV.replace({})
Ruby result: FOO is not set
Extension result: FOO is not setTEST: ENV["FOO"] = ""
Ruby result: FOO = ""
Extension result: FOO = ""
```### jRuby output
```
TEST: ENV["FOO"] = "something"
Ruby result: FOO = "something"
Extension result: FOO = "something"TEST: ENV.delete("FOO")
Ruby result: FOO is not set
Extension result: FOO = "something"TEST: ENV["FOO"] = nil
Ruby result: FOO is not set
Extension result: FOO = "something"TEST: ENV.update("FOO" => nil)
Ruby result: FOO is not set
Extension result: FOO = "something"TEST: ENV.clear && ENV.replace({})
Ruby result: FOO is not set
Extension result: FOO = "something"TEST: ENV["FOO"] = ""
Ruby result: FOO = ""
Extension result: FOO = ""
```