croods 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/README.md +28 -7
- data/lib/croods/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da70e6c23805cc55c8a4d7db9e97adc567a4bcd436fb0296600238e9826955c7
|
4
|
+
data.tar.gz: 43415c1a16fdefeaa51fc4dd5cf4b7c93121c8f16fbefefee5966af4ac714766
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ea56e2741d2559944657daeeb73ef18cee25a381da09e50fe5f430cc4ae008015ec241e60cf96b7c931cc998fce5333fdd7f13e9e978d6f4ca890ece42554b7
|
7
|
+
data.tar.gz: da63eb7581f72c974162b6c905d438ba7afa2b8f18b1c5d319d675e8821c7a3aae4fbb3a420f46f4c09b8548911a53fd2d1b3915b7609859fdac6be82c6ac2b2
|
data/README.md
CHANGED
@@ -4,9 +4,11 @@
|
|
4
4
|

|
5
5
|
|
6
6
|
# Croods
|
7
|
-
|
7
|
+
|
8
|
+
A framework for creating CRUDs in Rails APIs. https://croods-rails.netlify.app
|
8
9
|
|
9
10
|
## Installation
|
11
|
+
|
10
12
|
Add this line to your application's Gemfile:
|
11
13
|
|
12
14
|
```ruby
|
@@ -14,19 +16,23 @@ gem 'croods'
|
|
14
16
|
```
|
15
17
|
|
16
18
|
And then execute:
|
19
|
+
|
17
20
|
```bash
|
18
21
|
$ bundle
|
19
22
|
```
|
20
23
|
|
21
24
|
## Usage
|
25
|
+
|
22
26
|
### Resource
|
27
|
+
|
23
28
|
Resource is a generic abstraction for any object your app needs to represent. Instead of `app/models/` and `app/controllers/`, with croods we have `app/resources/`.
|
24
29
|
|
25
30
|
### Creating a resource
|
31
|
+
|
26
32
|
To add a `Project` resource to your app, start by generating a migration:
|
27
|
-
|
33
|
+
`rails g migration CreateProjects`
|
28
34
|
|
29
|
-
```
|
35
|
+
```ruby
|
30
36
|
# It's crucial to write really solid migrations
|
31
37
|
# croods will use your database schema to build your resources.
|
32
38
|
class CreateProjects < ActiveRecord::Migration[5.2]
|
@@ -38,8 +44,10 @@ class CreateProjects < ActiveRecord::Migration[5.2]
|
|
38
44
|
end
|
39
45
|
end
|
40
46
|
```
|
47
|
+
|
41
48
|
Then create the module and the main file `app/resources/projects/resource.rb`:
|
42
|
-
|
49
|
+
|
50
|
+
```ruby
|
43
51
|
module Projects
|
44
52
|
class Resource < ApplicationResource
|
45
53
|
end
|
@@ -47,12 +55,15 @@ end
|
|
47
55
|
```
|
48
56
|
|
49
57
|
Last step is to initialize your resource in `config/initializers/croods.rb`:
|
58
|
+
|
50
59
|
```ruby
|
51
60
|
Croods.initialize_for(:users, :projects)
|
52
61
|
```
|
53
62
|
|
54
63
|
### Skip actions
|
55
|
-
|
64
|
+
|
65
|
+
Croods creates five basic endpoints for your resource. If you don't want one, you need to skip its action:
|
66
|
+
|
56
67
|
```ruby
|
57
68
|
module Projects
|
58
69
|
class Resource < ApplicationResource
|
@@ -60,8 +71,11 @@ module Projects
|
|
60
71
|
end
|
61
72
|
end
|
62
73
|
```
|
74
|
+
|
63
75
|
### Skip attributes
|
76
|
+
|
64
77
|
By default, every single attribute in your table is exposed in your endpoints. If you don't want this, let croods know:
|
78
|
+
|
65
79
|
```ruby
|
66
80
|
module Projects
|
67
81
|
class Resource < ApplicationResource
|
@@ -71,7 +85,9 @@ end
|
|
71
85
|
```
|
72
86
|
|
73
87
|
### Extend model
|
88
|
+
|
74
89
|
Croods creates a model for your resource. It looks at your database and automatically infers your model's `belongs_to` associations. But if you need to add code to your model just use `extend_model`.
|
90
|
+
|
75
91
|
```ruby
|
76
92
|
module Projects
|
77
93
|
class Resource < ApplicationResource
|
@@ -83,6 +99,7 @@ end
|
|
83
99
|
```
|
84
100
|
|
85
101
|
Protip: you can create a Model module and `extend_model { include Projects::Model }`.
|
102
|
+
|
86
103
|
```ruby
|
87
104
|
module Projects
|
88
105
|
module Model
|
@@ -94,9 +111,12 @@ module Projects
|
|
94
111
|
end
|
95
112
|
end
|
96
113
|
```
|
114
|
+
|
97
115
|
### Authentication
|
116
|
+
|
98
117
|
Croods uses [devise_token_auth](https://github.com/lynndylanhurley/devise_token_auth) under the hood.
|
99
118
|
To customize which devise modules are loaded, you can pass them as arguments to `use_for_authentication!`
|
119
|
+
|
100
120
|
```ruby
|
101
121
|
use_for_authentication!(
|
102
122
|
:database_authenticatable,
|
@@ -112,14 +132,15 @@ use_for_authentication!(
|
|
112
132
|
You can manually check your changes in the dummy Rails app under `/todos`.
|
113
133
|
|
114
134
|
To set it up:
|
135
|
+
|
115
136
|
```
|
116
137
|
cd todos/
|
117
138
|
bin/setup
|
118
139
|
```
|
119
140
|
|
120
141
|
To run specs use:
|
121
|
-
|
142
|
+
`bin/rspec`
|
122
143
|
|
123
144
|
## License
|
124
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
125
145
|
|
146
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/croods/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: croods
|
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
|
- Daniel Weinmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: committee
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 5.2.4.
|
61
|
+
version: 5.2.4.3
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 5.2.4.
|
68
|
+
version: 5.2.4.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: schema_associations
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 4.0.
|
159
|
+
version: 4.0.1
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 4.0.
|
166
|
+
version: 4.0.1
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rspec_junit_formatter
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|