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.
If you do accept this PR then I suggest that you make me a collaborator of this repository.
One thing that this rewrite does not handle is auto-update, but since you’re not using GitHub Releases, it would appear that you were not actually making use of the alfred-workflow auto-update support.
I think there should be an auto-update feature, I can add this once I know whether or not you agree to make me a collaborator, as I think we should use GitHub Releases for updates.
Some of the changes/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 #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 #5, #16, #23, and #25.
You can also close #28 (but I already did that in 6006836b37aaef9335ca4f48eb87bb4beda27a23).
Add ruby version of workflow
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.
If you do accept this PR then I suggest that you make me a collaborator of this repository.
One thing that this rewrite does not handle is auto-update, but since you’re not using GitHub Releases, it would appear that you were not actually making use of the alfred-workflow auto-update support.
I think there should be an auto-update feature, I can add this once I know whether or not you agree to make me a collaborator, as I think we should use GitHub Releases for updates.
Some of the changes/improvements that this rewrite brings:
d > Clear Cache
andd > Set Cache [seconds]
because of the improved caching behavior.d >
, for exampled ns Budget
should now create a spreadsheet named “Budget”. Closes #11.d > Login
as we automatically open the Google Sign In page when refresh token is missing/invalid.d > Logout
tod Sign out of Google Drive
and made it perform an account sign out (instead of just deleting the access tokens).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.GET /
request (so not fooled by afavicon.ico
request or similar) and it uses a URL parser to obtain thecode
query parameter from the callback URL.The above should fix #5, #16, #23, and #25.
You can also close #28 (but I already did that in 6006836b37aaef9335ca4f48eb87bb4beda27a23).