app_rail-airtable 0.2.5 → 0.2.6
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/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/bin/ara_generator +1 -1
- data/lib/app_rail/airtable/generator.rb +1 -1
- data/lib/app_rail/airtable/sinatra.rb +24 -6
- data/lib/app_rail/airtable/version.rb +1 -1
- metadata +2 -3
- data/.byebug_history +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d893dd5ef7b42015a34fe0dd55738ef1296799ba40bd235c4fd1c84665d6048
|
4
|
+
data.tar.gz: 0bd37ae820e88d1198cd7e82a0d8a965d893d0d4c8dc32bc33975f7f7a95cbcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a4fe2f30b7b4ef404062e5396d304abf584873b1bfb5bf32d81ed3f8d5f04a01172bac29600ed83f7e347ba28267e670ce083e5aa0b93e886357b00042bfe73
|
7
|
+
data.tar.gz: 23cf52db82ae5ba37f9ea00751f867a93b7d1f800f480810b21e932e4cfec3792eede5a3569b3b0baba1143991d415e6a09c031bee7d981196d8ebcbfca2cfaf
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/bin/ara_generator
CHANGED
@@ -23,24 +23,42 @@ end
|
|
23
23
|
module AppRail
|
24
24
|
module Airtable
|
25
25
|
class Sinatra < Sinatra::Base
|
26
|
+
|
27
|
+
helpers do
|
28
|
+
def request_body_as_json
|
29
|
+
request.body.rewind
|
30
|
+
JSON.parse(request.body.read)
|
31
|
+
end
|
32
|
+
end
|
26
33
|
|
27
|
-
def self.resources(name)
|
34
|
+
def self.resources(name, only: [:index, :show, :create])
|
35
|
+
only = [only] if only.is_a?(Symbol)
|
36
|
+
|
37
|
+
index_route(name) if only.include?(:index)
|
38
|
+
show_route(name) if only.include?(:show)
|
39
|
+
create_route(name) if only.include?(:create)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.index_route(name)
|
28
43
|
get "/#{name.to_s}" do
|
29
44
|
name.classify_constantize.index.map(&:ar_list_item_as_json).to_json
|
30
45
|
end
|
31
|
-
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.show_route(name)
|
32
49
|
get "/#{name.to_s}/:id" do
|
33
50
|
name.classify_constantize.find(params['id']).ar_stack_as_json.to_json
|
34
51
|
end
|
35
|
-
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.create_route(name)
|
36
55
|
post "/#{name.to_s}" do
|
37
56
|
request.body.rewind # in case someone already read it
|
38
57
|
data = JSON.parse(request.body.read)
|
39
|
-
|
40
|
-
[201,
|
58
|
+
as_json = name.classify_constantize.create_with_params_as_json(data.merge(params))
|
59
|
+
[201, as_json.to_json]
|
41
60
|
end
|
42
61
|
end
|
43
|
-
|
44
62
|
end
|
45
63
|
end
|
46
64
|
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.6
|
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-
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -102,7 +102,6 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- ".DS_Store"
|
105
|
-
- ".byebug_history"
|
106
105
|
- ".gitignore"
|
107
106
|
- ".rspec"
|
108
107
|
- ".travis.yml"
|
data/.byebug_history
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
exit
|
2
|
-
@table_definitions.first.all.first.fields.keys
|
3
|
-
@table_definitions.first.all.first.fields
|
4
|
-
@table_definitions.first.all.first
|
5
|
-
@table_definitions.first.first
|
6
|
-
@table_definitions.first.instance_variable_get("@fields")
|
7
|
-
@table_definitions.first.instance_variable_get("fields")
|
8
|
-
@table_definitions.first.instance_variable_get("@fields")
|
9
|
-
@table_definitions.first.fields
|
10
|
-
@table_definitions.first.table_name
|
11
|
-
@table_definitions.first.name
|
12
|
-
@table_definitions.first.all
|
13
|
-
@table_definitions.first
|
14
|
-
@table_definitions
|