Skip to content

Commit

Permalink
feat(doc): Add README instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentinchampenois committed Apr 2, 2024
1 parent 1560bdb commit b5be8cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# Grist

TODO: Delete this and the text below, and describe your gem

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/grist`. To experiment with that code, run `bin/console` for an interactive prompt.
Grist ruby library to interact with Grist API.

## Installation

TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
Add this line to your application's Gemfile:

Install the gem and add to the application's Gemfile by executing:
```ruby
gem "grist", git: "https://github.com/quentinchampenois/grist.git"
```

$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
_First release will be published on RubyGems_

If bundler is not being used to manage dependencies, install the gem by executing:
## Examples

$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
List all organizations

## Usage
```ruby
require "faraday"
require "grist"

TODO: Write usage instructions here
client = Grist::Client.new(url: "http://localhost:8484", token: "API_TOKEN")
puts client.organizations
```

## Development

Expand All @@ -28,7 +32,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/grist. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/grist/blob/main/CODE_OF_CONDUCT.md).
Bug reports and pull requests are welcome on GitHub at https://github.com/quentinchampenois/grist.

## License

Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "faraday"
require "grist"

# You can add fixtures and/or initialization code here to make experimenting
Expand Down
14 changes: 7 additions & 7 deletions lib/grist/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
module Grist
module HTTP
def get(path, **_params)
request(method: :get, path: path)
request(method: :get, path: "/api#{path}")
end

def post(path, **params)
request(method: :post, path: path, payload: params)
request(method: :post, path: "/api#{path}", payload: params)
end

def put(path, **params)
request(method: :put, path: path, payload: params)
request(method: :put, path: "/api#{path}", payload: params)
end

def patch(path, **params)
request(method: :patch, path: path, payload: params)
request(method: :patch, path: "/api#{path}", payload: params)
end

def destroy(path, **_params)
request(method: :delete, path: path)
request(method: :delete, path: "/api#{path}")
end

def conn
Faraday.new(url: @url) do |c|
::Faraday.new(url: @url) do |c|
c.request :json
c.request :authorization, "Bearer", @token

Expand All @@ -37,7 +37,7 @@ def conn

def request(method: nil, path: "", payload: nil, headers: {})
connection.send(method, path, payload, headers)
rescue Faraday::Error => e
rescue ::Faraday::Error => e
puts e.response[:status]
puts e.response[:body]
end
Expand Down

0 comments on commit b5be8cb

Please sign in to comment.