-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
1 parent
99de0da
commit e64c83f
Showing
3 changed files
with
30 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
``` | ||
$ git clone https://github.com/lucasocon/openweather.git | ||
RUBYOPT='-I samples/truffle/interop/weather/openweather/lib -I samples/truffle/interop/weather' graalvm/bin/js samples/truffle/interop/weather/weather.js | ||
``` | ||
|
||
The demo hangs after printing the temperature, as some Ruby service threads | ||
get stuck and aren't shutting down properly. | ||
|
||
The Ruby `temperature_in_city` method has a `this` parameter which it wouldn't | ||
normally have, because JS passes `this` as the first argument. |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Interop.eval('application/x-ruby', 'require "weather"'); | ||
|
||
temperature_in_city = Interop.import('temperature_in_city') | ||
|
||
console.log('Temperature in New York now: ' + temperature_in_city('New York') + '℃'); |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'openweather2' | ||
|
||
Openweather2.configure do |config| | ||
# This is the endpoint and API key from the tests in the Openweather2 gem | ||
config.endpoint = 'http://api.openweathermap.org/data/2.5/weather' | ||
config.apikey = 'dd7073d18e3085d0300b6678615d904d' | ||
end | ||
|
||
def temperature_in_city(this, name) | ||
name = Truffle::Interop.from_java_string(name) | ||
weather = Openweather2.get_weather(city: name, units: 'metric') | ||
weather.temperature | ||
end | ||
|
||
Truffle::Interop.export_method :temperature_in_city |
e64c83f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasstadler I've written this using JS instead of R, because I'm not as familiar with how R works. Can you translate to R? You'll need
489d4316b0d8178b75e9990d8cd729edf23dad95
of GraalVM.e64c83f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I can do the translation. thanks a lot for the example!