supabase_api 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ee663907558d623c67c158f5fdfdad29ace31bf9d15a8163e831d638fb692e2
4
- data.tar.gz: 68e363c2c76fc08a314770f37a0d3523e6e37da3429bae85ab7392203856eeac
3
+ metadata.gz: 84f7e5cb75c6780f9e5d92c3754ba8bc47a4025435138c15a3eca2277bf94c0b
4
+ data.tar.gz: 3e8dd8a4d6660f151ad4e710a6b2deddc00ffa053246a97936473f13dd373b2a
5
5
  SHA512:
6
- metadata.gz: 7e2002ed63e05801f30f65aea4c3b75fcd4419a9d81f67640f1f572f97fda35842357aebae70907a2210c638b6fd24abf9b76c9b3d1fdf70f051d94d6138785a
7
- data.tar.gz: 99a263b473b85f14f95172da8770efac671a450b05e8cf7d3dfb31ef4e7b03f6bbaac054d4c3a298c0f24437ad59d8fa14c97915f189f95269e3992171af18d7
6
+ metadata.gz: 29bada7921d062dd522ceb7859c846649859c9032e571914af230275c1f109cdd712f2121a920d82cb8ccc56131f10340486b83c2d97e5a0387a982634555796
7
+ data.tar.gz: c265459ec9dae8192f9637a6c80711fc5966aa6a55880b9a1132598b266fa5dd6ae35d1209ad933bf26498f8ace7419a964af5157ed707e83d90bd6cdaa878c0
data/README.md CHANGED
@@ -1,22 +1,87 @@
1
1
  # SupabaseApi
2
2
 
3
- 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/supabase_api`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Hi, this is a Ruby wrapper to access your Supabase tables via REST API in a manner similar to ActiveRecord model.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ DISCLAIMER: This is not an official Ruby SDK.
6
6
 
7
7
  ## Installation
8
8
 
9
9
  Install the gem and add to the application's Gemfile by executing:
10
10
 
11
- $ bundle add supabase_api
11
+ ```bash
12
+ $ bundle add supabase_api
13
+ ```
12
14
 
13
15
  If bundler is not being used to manage dependencies, install the gem by executing:
14
16
 
15
- $ gem install supabase_api
17
+ ```bash
18
+ $ gem install supabase_api
19
+ ```
16
20
 
17
21
  ## Usage
18
22
 
19
- TODO: Write usage instructions here
23
+
24
+ ### Setup
25
+ Run these commands on the config or initializer file.
26
+
27
+ ```ruby
28
+ # setups
29
+ require 'supabase_api' # if not using Rails
30
+ SupabaseApi::Sample.base_url = 'https://yourrandomapisubdomain.supabase.co'
31
+ SupabaseApi::Sample.api_key = 'veryrandomlongstring'
32
+ ```
33
+
34
+ ### With Rails
35
+ Create a ruby PORO class for your Supabase tables and inherit from the `SupabaseApi::Record` class.
36
+
37
+ ```ruby
38
+ class Book < SupabaseApi::Record
39
+ def self.table_name
40
+ # put the name of the table you want to connect with from Supabase
41
+ 'books' # or 'Books', whatever you fancy
42
+ end
43
+ end
44
+ ```
45
+
46
+ Then after that you can access your Supabase table just like a `ActiveRecord`-backed models.
47
+
48
+ ```ruby
49
+ book_id_in_supabase = 100
50
+ Book.find(book_id_in_supabase)
51
+
52
+ # The line below will yield the same like above but will not raise any exception
53
+ book = Book.find_by_id(book_id_in_supabase)
54
+
55
+ # Assuming the books table has 'status' string column
56
+ book.status = 'archived'
57
+ book.save
58
+
59
+ # If you want to create a new book record
60
+ new_book = Book.new(
61
+ name: 'New Book',
62
+ status: 'pending'
63
+ )
64
+ new_book.save
65
+
66
+ # or
67
+ book = Book.create(
68
+ name: 'New Book',
69
+ status: 'pending'
70
+ )
71
+ book.id # => 100
72
+
73
+ # In case you regret creating it, you can delete the record
74
+ book.destroy
75
+ Book.find(100) # will raise an exception SupabaseApi::RecordNotFound
76
+ ```
77
+
78
+ ## TODO List
79
+ - add pagination.
80
+ - add command `.where` for the Record class to be able to query the table.
81
+ - add command `.update` for the Record instance.
82
+ - add command `#update` for the Record class to have multiple upserts.
83
+ - add more graceful and robust error handler.
84
+
20
85
 
21
86
  ## Development
22
87
 
@@ -26,7 +91,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
26
91
 
27
92
  ## Contributing
28
93
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/supabase_api. 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]/supabase_api/blob/master/CODE_OF_CONDUCT.md).
94
+ Bug reports and pull requests are welcome on GitHub at https://github.com/galliani/supabase_api. 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/galliani/supabase_api/blob/master/CODE_OF_CONDUCT.md).
30
95
 
31
96
  ## License
32
97
 
@@ -34,4 +99,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
34
99
 
35
100
  ## Code of Conduct
36
101
 
37
- Everyone interacting in the SupabaseApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/supabase_api/blob/master/CODE_OF_CONDUCT.md).
102
+ Everyone interacting in the SupabaseApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/galliani/supabase_api/blob/master/CODE_OF_CONDUCT.md).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SupabaseApi
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/supabase_api.gemspec CHANGED
@@ -6,7 +6,6 @@ Gem::Specification.new do |spec|
6
6
  spec.name = "supabase_api"
7
7
  spec.version = SupabaseApi::VERSION
8
8
  spec.authors = ["Galih Muhammad"]
9
- spec.email = ["galih.rubyist@gmail.com"]
10
9
 
11
10
  spec.summary = "A ruby client for Supabase tables to be consumed as ruby class via the REST API"
12
11
  spec.homepage = "https://github.com/galliani/supabase_api"
@@ -32,7 +31,4 @@ Gem::Specification.new do |spec|
32
31
 
33
32
  # Uncomment to register a new dependency of your gem
34
33
  spec.add_dependency "httparty"
35
-
36
- # For more information and examples about making a new gem, check out our
37
- # guide at: https://bundler.io/guides/creating_gem.html
38
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supabase_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Galih Muhammad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-10 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -26,7 +26,6 @@ dependencies:
26
26
  version: '0'
27
27
  description:
28
28
  email:
29
- - galih.rubyist@gmail.com
30
29
  executables: []
31
30
  extensions: []
32
31
  extra_rdoc_files: []