croods 0.2.0 → 0.2.1

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: b1b0dd2406b59f7c88e4488699e1681249f92da22dd31c2c71abe850755d8439
4
- data.tar.gz: 203bf41a0d129e931037de59e07588c49c906ee0b8c0cc592db3e8ca04b8c8e6
3
+ metadata.gz: 650a72062d9460d74e7efa322db3df3ec47e972ed475674aac75f7b05daa6fe9
4
+ data.tar.gz: ecdca75bcdadcb9cf07fa97ce5cd5495fca20d29a47a6b40d5c18613aa005d54
5
5
  SHA512:
6
- metadata.gz: c7bcb1d81082fdd67a1104c23460f6efc33139b4334ac64cbdd5ef34aa44a71a14a810e339f4be1eea66e0a4a3162843525db72201fb0b1e602d6c502eeb2b62
7
- data.tar.gz: 6f003b69476c254f700d3dafbcc690f969e319452f52b97869c5a20d1b3c0a269acc572cb3ac3a1114fae6102fcbd10b53d0bbcffb74fd4401bb5f4c3a0496a9
6
+ metadata.gz: 927e71afb7f0cc1f3141dcf8e1c2616b9090008d3aa80c2da54d83a8a15ff554d67af02d73c6958680c8a97a9b0122593e48288ea4960943b7a2c74817cf2c38
7
+ data.tar.gz: f63bb7198a6268b4e3ee192689e094a7e58d3476d0b4206569a5a6ae14f713fce1f2f45ba9262594a970d347224a8e587f281b1ef4cd17d8563f5bf6f5a93757
data/README.md CHANGED
@@ -1,9 +1,98 @@
1
+ [![CircleCI](https://circleci.com/gh/SeasonedSoftware/croods-rails.svg?style=svg)](https://circleci.com/gh/SeasonedSoftware/croods-rails)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/5531c26549b427684578/maintainability)](https://codeclimate.com/github/SeasonedSoftware/croods-rails/maintainability)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/5531c26549b427684578/test_coverage)](https://codeclimate.com/github/SeasonedSoftware/croods-rails/test_coverage)
4
+
1
5
  # Croods
2
6
  Short description and motivation.
3
7
 
4
8
  ## Usage
5
- How to use my plugin.
9
+ ### Resource
10
+ 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/`.
11
+
12
+ ### Creating a resource
13
+ To add a `Project` resource to your app, start by generating a migration:
14
+ ```rails g migration CreateProjects```
15
+
16
+ ``` ruby
17
+ # It's crucial to write really solid migrations
18
+ # croods will use your database schema to build your resources.
19
+ class CreateProjects < ActiveRecord::Migration[5.2]
20
+ def change
21
+ create_table :projects do |t|
22
+ t.string :name, null: false
23
+ t.timestamps
24
+ end
25
+ end
26
+ end
27
+ ```
28
+ Then create the module and the main file `app/resources/projects/resource.rb`:
29
+ ```ruby
30
+ module Projects
31
+ class Resource < ApplicationResource
32
+ end
33
+ end
34
+ ```
35
+
36
+ Last step is to initialize your resource in `config/initializers/croods.rb`:
37
+ ```ruby
38
+ Croods.initialize_for(:users, :projects)
39
+ ```
40
+
41
+ ### Skip actions
42
+ Croods creates five basic endpoints for your resource. If you don't want one, you need to skip it's action:
43
+ ```ruby
44
+ module Projects
45
+ class Resource < ApplicationResource
46
+ skip_actions :index, :create, :update, :show, :destroy
47
+ end
48
+ end
49
+ ```
50
+ ### Skip attributes
51
+ By default, every single attribute in your table is exposed in your endpoints. If you don't want this, let croods know:
52
+ ```ruby
53
+ module Projects
54
+ class Resource < ApplicationResource
55
+ skip_attributes :created_at, :updated_at
56
+ end
57
+ end
58
+ ```
59
+
60
+ ### Extend model
61
+ 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`.
62
+ ```ruby
63
+ module Projects
64
+ class Resource < ApplicationResource
65
+ extend_model do
66
+ before_create :do_somethig
67
+ end
68
+ end
69
+ end
70
+ ```
71
+
72
+ Protip: you can create a Model module and `extend_model { include Projects::Model }`.
73
+ ```ruby
74
+ module Projects
75
+ module Model
76
+ extend ActiveSupport::Concern
6
77
 
78
+ included do
79
+ before_create :do_something
80
+ end
81
+ end
82
+ end
83
+ ```
84
+ ### Authentication
85
+ Croods uses [devise_token_auth](https://github.com/lynndylanhurley/devise_token_auth) under the hood.
86
+ To customize which devise modules are loaded, you can pass them as arguments to `use_for_authentication!`
87
+ ```ruby
88
+ use_for_authentication!(
89
+ :database_authenticatable,
90
+ :recoverable,
91
+ :rememberable,
92
+ :trackable,
93
+ :validatable
94
+ )
95
+ ```
7
96
  ## Installation
8
97
  Add this line to your application's Gemfile:
9
98
 
@@ -21,8 +110,20 @@ Or install it yourself as:
21
110
  $ gem install croods
22
111
  ```
23
112
 
113
+
24
114
  ## Contributing
25
- Contribution directions go here.
115
+
116
+ You can manually check your changes in the dummy Rails app under `/todos`.
117
+
118
+ To set it up:
119
+ ```
120
+ cd todos/
121
+ bin/setup
122
+ ```
123
+
124
+ To run specs use:
125
+ ```bin/rspec```
26
126
 
27
127
  ## License
28
128
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
129
+
@@ -4,7 +4,12 @@ module Croods
4
4
  module Resource
5
5
  module JsonSchema
6
6
  module Definition
7
- TYPES = { datetime: 'string', text: 'string', json: 'object' }.freeze
7
+ TYPES = {
8
+ datetime: 'string',
9
+ text: 'string',
10
+ json: 'object',
11
+ float: 'number'
12
+ }.freeze
8
13
 
9
14
  class << self
10
15
  def schema(attribute)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Croods
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
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.0
4
+ version: 0.2.1
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-04-20 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: committee
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 4.0.0.rc1
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspec_junit_formatter
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.4.1
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.4.1
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: rubocop
169
183
  requirement: !ruby/object:Gem::Requirement