api_maker_table 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +8 -0
- data/app/api_maker/resources/table_setting_column_resource.rb +10 -0
- data/app/api_maker/resources/table_setting_resource.rb +21 -0
- data/app/models/api_maker_table/application_record.rb +5 -0
- data/app/models/api_maker_table/table_setting.rb +7 -0
- data/app/models/api_maker_table/table_setting_column.rb +7 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20220526073326_create_table_settings.rb +11 -0
- data/db/migrate/20220526073350_create_table_setting_columns.rb +16 -0
- data/lib/api_maker_table/engine.rb +5 -0
- data/lib/api_maker_table/version.rb +3 -0
- data/lib/api_maker_table.rb +6 -0
- data/lib/tasks/api_maker_table_tasks.rake +4 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cb01aa0fdd8e6efecfb54d3b783dd45a386375fb084ee6ff5561684ec1393187
|
4
|
+
data.tar.gz: 27e66e0459a42371339902e94150bd941a912e73299933a887a451b923411237
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71e5ebb258e2b5c46bb8189c957b62207cc924fe060c94d2ed299102459c6565c15d572b7d691b477504369f30e48f5d03e208dce42da9ca9fcbf8d0b396b3fd
|
7
|
+
data.tar.gz: 2723674cce83676d32961c8cb722a45548cbbdca01a1c71da415f7871982d3b5c74e9e2fee1707faf8201e609fa1cd150aaa42de9dc78a30de5a639b1d1deb04
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2022 kaspernj
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# ApiMakerTable
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "api_maker_table"
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install api_maker_table
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
class Resources::TableSettingColumnResource < ApiMaker::BaseResource
|
2
|
+
self.model_class_name = "ApiMakerTable::TableSettingColumn"
|
3
|
+
|
4
|
+
attributes :attribute_name, :id, :identifier, :path, :position, :sort_key, :visible
|
5
|
+
relationships :table_setting
|
6
|
+
|
7
|
+
def abilities
|
8
|
+
can CRUD, ApiMakerTable::TableSettingColumn, table_setting: {user_id: current_user.id, user_type: current_user.class.name} if current_user
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Resources::TableSettingResource < ApiMaker::BaseResource
|
2
|
+
self.model_class_name = "ApiMakerTable::TableSetting"
|
3
|
+
|
4
|
+
attributes :id, :identifier
|
5
|
+
relationships :columns
|
6
|
+
|
7
|
+
def abilities
|
8
|
+
puts "Allow creating table for: #{{user_id: current_user.id, user_type: current_user.class.name}}"
|
9
|
+
|
10
|
+
can CRUD, ApiMakerTable::TableSetting, user_id: current_user.id, user_type: current_user.class.name if current_user
|
11
|
+
end
|
12
|
+
|
13
|
+
def permitted_params(arg)
|
14
|
+
arg.params.require(:table_setting).permit(
|
15
|
+
:identifier,
|
16
|
+
:user_id,
|
17
|
+
:user_type,
|
18
|
+
columns_attributes: [:attribute_name, :id, :identifier, :path, :position, :sort_key, :visible]
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateTableSettings < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :table_settings do |t|
|
4
|
+
t.references :user, limit: 36, null: false, polymorphic: true, type: :string
|
5
|
+
t.string :identifier, index: true, null: false
|
6
|
+
t.timestamps
|
7
|
+
end
|
8
|
+
|
9
|
+
add_index :table_settings, [:user_id, :user_type, :identifier], unique: true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateTableSettingColumns < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :table_setting_columns do |t|
|
4
|
+
t.references :table_setting, foreign_key: true, null: false
|
5
|
+
t.string :identifier, index: true, null: false
|
6
|
+
t.string :attribute_name
|
7
|
+
t.text :path
|
8
|
+
t.string :sort_key
|
9
|
+
t.integer :position, null: false
|
10
|
+
t.boolean :visible, default: true, null: false
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :table_setting_columns, [:table_setting_id, :identifier], unique: true
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: api_maker_table
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kaspernj
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 7.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 7.0.0
|
27
|
+
description: A Rails gem for generating a JavaScript API automatically based on your
|
28
|
+
ActiveRecord models.
|
29
|
+
email:
|
30
|
+
- k@spernj.org
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- MIT-LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- app/api_maker/resources/table_setting_column_resource.rb
|
39
|
+
- app/api_maker/resources/table_setting_resource.rb
|
40
|
+
- app/models/api_maker_table/application_record.rb
|
41
|
+
- app/models/api_maker_table/table_setting.rb
|
42
|
+
- app/models/api_maker_table/table_setting_column.rb
|
43
|
+
- config/routes.rb
|
44
|
+
- db/migrate/20220526073326_create_table_settings.rb
|
45
|
+
- db/migrate/20220526073350_create_table_setting_columns.rb
|
46
|
+
- lib/api_maker_table.rb
|
47
|
+
- lib/api_maker_table/engine.rb
|
48
|
+
- lib/api_maker_table/version.rb
|
49
|
+
- lib/tasks/api_maker_table_tasks.rake
|
50
|
+
homepage: https://github.com/kaspernj/api_maker
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.2.32
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: A Rails gem for generating a JavaScript API automatically based on your ActiveRecord
|
73
|
+
models.
|
74
|
+
test_files: []
|