app_rail-airtable 0.2.6 → 0.2.7
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/app_rail/airtable/application_record.rb +1 -1
- data/lib/app_rail/airtable/sinatra.rb +17 -11
- data/lib/app_rail/airtable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59112ddcce193bb297ccdb3cebd972445183c4a9e755a1ccb7c91c695f600bb9
|
4
|
+
data.tar.gz: ee3d1ff83a53b53f367aa7c84781113457a037abf4257a9d7ccf2589a167e456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5099f41bc41cc4a744e49586c2f727cca97cb1054131144094f1c3bbe3cbaac8acb020909acae4903d92920348a738f70ebac45f18a9150a1b3c6246b8e17807
|
7
|
+
data.tar.gz: 4afb93f8f41cd9a306b1a5262fafcc30127f7c0df95c51e82b76fabf0a04b8e8e114381a432d44fb382e835021edbc5dcdc2727bee2bda12c6b23fdc5aad1b6e
|
data/Gemfile.lock
CHANGED
@@ -2,6 +2,7 @@ require 'sinatra'
|
|
2
2
|
require 'json'
|
3
3
|
require 'active_support'
|
4
4
|
|
5
|
+
# TODO: MBS - move to configure block or other
|
5
6
|
Airrecord.api_key = ENV.fetch("AIRTABLE_API_KEY")
|
6
7
|
|
7
8
|
class Symbol
|
@@ -29,33 +30,38 @@ module AppRail
|
|
29
30
|
request.body.rewind
|
30
31
|
JSON.parse(request.body.read)
|
31
32
|
end
|
33
|
+
|
34
|
+
def params_and_json_body
|
35
|
+
request_body_as_json.merge(params)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
|
-
def self.resources(name, only: [:index, :show, :create])
|
39
|
+
def self.resources(name, only: [:index, :show, :create], authenticated: false)
|
35
40
|
only = [only] if only.is_a?(Symbol)
|
36
41
|
|
37
|
-
index_route(name) if only.include?(:index)
|
38
|
-
show_route(name) if only.include?(:show)
|
39
|
-
create_route(name) if only.include?(:create)
|
42
|
+
index_route(name, authenticated) if only.include?(:index)
|
43
|
+
show_route(name, authenticated) if only.include?(:show)
|
44
|
+
create_route(name, authenticated) if only.include?(:create)
|
40
45
|
end
|
41
46
|
|
42
|
-
def self.index_route(name)
|
47
|
+
def self.index_route(name, authenticated)
|
43
48
|
get "/#{name.to_s}" do
|
44
|
-
|
49
|
+
authenticate! if authenticated
|
50
|
+
name.classify_constantize.index(authenticated ? current_user : nil).map(&:ar_list_item_as_json).to_json
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
48
|
-
def self.show_route(name)
|
54
|
+
def self.show_route(name, authenticated)
|
49
55
|
get "/#{name.to_s}/:id" do
|
56
|
+
authenticate! if authenticated
|
50
57
|
name.classify_constantize.find(params['id']).ar_stack_as_json.to_json
|
51
58
|
end
|
52
59
|
end
|
53
60
|
|
54
|
-
def self.create_route(name)
|
61
|
+
def self.create_route(name, authenticated)
|
55
62
|
post "/#{name.to_s}" do
|
56
|
-
|
57
|
-
|
58
|
-
as_json = name.classify_constantize.create_with_params_as_json(data.merge(params))
|
63
|
+
authenticate! if authenticated
|
64
|
+
as_json = name.classify_constantize.create_with_params_as_json(params_and_json_body)
|
59
65
|
[201, as_json.to_json]
|
60
66
|
end
|
61
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_rail-airtable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brooke-Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|