-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Downloading exercises directly into Pharo #32
Comments
There is an issue in exercism to document this better: exercism/exercism#4087 |
Here is my experiment... https://github.com/bencoman/pharogui-exercism |
The first job is to see what its service API looks like. Exercism makes this easy with its commandline tool providing a very useful '--verbose' flag to show the operation of CLI commands e.g. ConfigureGet your API key YOUR_TOKEN here... https://exercism.io/my/settings
Downloading exercises with CLIExercises are downloaded for a track with the 'download' command, e.g...
the output of which is...
and now there is a new directory "C:\Users...\Exercism\go\hello-world" holding three downloaded files and a fourth file holding solution metadata. |
Experimenting in Pharo Playground with established track, e.g. "Go"Install NeoJSONTools > Catalog Browser... NeoJSON > Install stable version. Then in Playground...
More advanced NeoJSON can parse that directly into instance variables,
Then we can download the files' contents into a collection of Strings...
So that demonstrates using NeoJSON to download Exercism track/exercise into Strings we can work with. |
Downloading exercises directly into PharoI haven't managed to look at the existing tool yet, and this POC is short enough, so I'm just listing the code here in the issue. Here is some discussion about programatically loading Tonel files. Using a Command Pattern, i.e. simple classes, one per CLI command. e.g.
which is faciliated by the following code (presuming NeoJson installed per last post)...
|
@macta @samWson I'm not in a position to integrate the above with the existing tool, but I saw comments about OSProcess issues on Windows and managed to divert a few hours to updating my previous experiment to the new Excercism-V2 API. Proof of concept is working with hello-world from the Pharo track. |
@kytrinyx (for interest only), two posts above shows 45 lines for downloading exercises directly into Pharo. |
@macta A quick update. I hacked together a ZnClient in the playground and got back a good 200 response from Exercism. It wasn't difficult, just some trial and error. And I've been building this on my Windows machine to be sure. There may be a problem with getting the exercism authentication key from the users The good news is that I don't think this will be difficult or a hack. I'll play around with this some more tomorrow and hopefully have something to show here soon. |
@samWson Try this quick test...
|
Thanks @bencoman I realized what my problem was. It helps to read the file and not the directory holding the file. @bencoman I've only just this moment read your code above in depth. Looks like you have our solution all thought out already.
If you want I can try to get this integrated into ExercismManager over the next few days. |
Hi guys - I've not had any spare time, but it sounds like you've made some great progress on this - keep going, and I can pr it. If you leave info here - if some time surfaces I can jump back in and help again. |
This is super exciting! |
@bencoman - nice work, it fitted in pretty seamlessly. @samWson - wasn't sure if you had actually started to try and integrate (if so, interested in comparing your solution to mine - and of course I had the advantage of writing the initial bits so could spot how to do it quickly). We now need the equivalent foo for submitting files back to Exercism - and then we can get rid of OSProcess (although it would mean we lose the ability to launch the exercism web page from a pharo menu item - but there might be a simpler way to do that, as OSProcess loads quite a lot of cross platform code - although obviously not enough from the problem we hit) |
Downloading/submitting exercises directly with the Exercism site doesn't
mean OSProcess needs to be abandoned for other functions - particularly
cases where you don't need to wait for the external command to complete,
like opening a web browser.
However here is a possible alternative (though I've not played with it yet)
https://github.com/seandenigris/Pharo-Web-Browser
http://forum.world.st/ANN-General-WebBrowser-package-for-Pharo4-and-Pharo-5-onwards-td4889670.html
|
@macta You had your solution finished before I started. It would have taken me much longer to try an integrate it into what we already had anyway. At the moment I'm going to take a look at the problem of submitting exercises. I'll do much the same approach as before: examine the CLI verbose output, and knock together a ZnClent in the playground to do the same thing. |
That would be awesome, if you can work out the foo - we can quickly integrate that bit too. I suspect submission may be a bit more involved, but hopefully not too much. |
With issue #96 fixed I think this issue can be closed now. |
Currently Pharo Exercism uses OSProcess to communicate with Exercism. @bencoman experimented with using a direct http connection and using the exercism protocol. This feels like a cleaner solution as shelling out to the os and parsing the osprocess result is more error prone than getting direct http results.
(We currently have a half way house where we can download directly but not yet upload)
The text was updated successfully, but these errors were encountered: