Skip to content

Commit

Permalink
Add ruby version of workflow
Browse files Browse the repository at this point in the history
I realize that it is not popular to change the implementation to another language, but I felt a major refactoring was called for to continue adding desired features, and as I work a lot faster in ruby, I decided to do it in ruby.

Some of the improvements that this rewrite brings:

- When we have cached data, we immediately return a response to Alfred based on the cache. If the cace is older than 10 minutes, we refresh the cache _in a background process_ and instruct Alfred to reload the list again after 0.8 seconds.
- Removed `d > Clear Cache` and `d > Set Cache [seconds]` because of the improved caching behavior.
- The create actions accept an optional document name and are no longer under `d >`, for example `d ns Budget` should now create a spreadsheet named “Budget”. Closes azai91#11.
- Removed `d > Login` as we automatically open the Google Sign In page when refresh token is missing/invalid.
- Changed `d > Logout` to `d Sign out of Google Drive` and made it perform an account sign out (instead of just deleting the access tokens).
- Refresh access token when expiration time is less than 10 seconds into the future. This avoids an extra (failing) server request/response, which is mainly for the document creation actions, as Google’s servers are on the slow side.
- The OAuth2 HTTP callback server is running in our main process, this means that we can perform actions that require authentication _after_ we receive the callback from Google, for example `d new document` without a valid token will now first ask the user to sign in and _then_ create the new document. It also improves robustness slightly because error handling is in the same process.
- Cache is refreshed (in the background) after creating a new document.
- Add verbose (timestamped) logging which should make troubleshooting easier.
- The OAuth2 HTTP callback server will run until we see the expected `GET /` request (so not fooled by a `favicon.ico` request or similar) and it uses a URL parser to obtain the `code` query parameter from the callback URL.

The above should fix azai91#5, azai91#16, azai91#23, and azai91#25.

You can also close azai91#28 (but I already did that in 6006836).
  • Loading branch information
sorbits committed Aug 24, 2017
1 parent 4ce233e commit b9105c9
Showing 1 changed file with 419 additions and 0 deletions.
Loading

0 comments on commit b9105c9

Please sign in to comment.