Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A Google Sheets api adapter in ruby
Add this line to your application's Gemfile:
gem 'g_sheets'
And then execute:
$ bundle
Or install it yourself as:
$ gem install g_sheets
We're using the dotenv
gem so you can just place your environment variables inside a file called .env
and add that file to your .gitignore
list; that way your authentication keys are kept safe.
If you wish to access user's data, you will need to create credentials for an OAuth client ID
. Please see the documentation on how to get the client id and secret.
In order to make operations on a user's Google Spreadsheet you will need an authentication token. There is a sample console OAuth token generator available in GSheets::Oauth
CLIENT_ID = ENV["CLIENT_ID"]; CLIENT_SECRET = ENV["CLIENT_SECRET"]
authenticator = GSheets::Oauth::Offline.new(CLIENT_ID, CLIENT_SECRET)
uri = authenticator.get_authentication_uri
puts "Please open #{uri.to_s} in your browser, accept the permissions, and copy-paste the code"
code = $stdin.gets.chomp
refresh_token = authenticator.get_refresh_token(authentication_code: code)
access_token = authenticator.get_access_token(refresh_token: refresh_token)
Save the refresh_token
somewhere safe, as it would be used later to create a new get_access_token
when that expires.
After that, you can now create a Session
object from the access_token
and instantiate a SpreadSheet
object from the session:
session = GSheets::Session.new(access_token: access_token)
# you need a spreadsheet id; try "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
# which is the sample db from the official docs
ss = GSheets::SpreadSheet.new(session: session, id: id)
ss.sheets.first.rows # returns all the rows in the first sheet of this spreadsheet
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
You can also run bundle exec rake console
to get a pry
console running with all files required.
Please see the documentation on the sheets api if you'd like to add more functionality :)
Bug reports and pull requests are welcome on GitHub at https://github.com/parasquid/g_sheets.
TODO:
FAQs
Unknown package
We found that g_sheets demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.