undercarriage 0.4.0 → 0.5.4
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 +19 -3
- data/lib/undercarriage/controllers/action_concern.rb +16 -0
- data/lib/undercarriage/controllers/restful/actions/create_concern.rb +14 -6
- data/lib/undercarriage/controllers/restful/actions/destroy_concern.rb +8 -1
- data/lib/undercarriage/controllers/restful/actions/update_concern.rb +14 -6
- data/lib/undercarriage/controllers/restful/flash_concern.rb +2 -2
- data/lib/undercarriage/controllers/restful/utility_concern.rb +4 -3
- data/lib/undercarriage/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31eecbc405432e03696e5e1bbf2de1a51f9c8283b98027d10732272527df8a89
|
4
|
+
data.tar.gz: 78fdc57d5373a23c9f265a2fc6229798f51c38d5b08afe851301989a58ef5c20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1fd30ade971146c1da5575c7a8023491f9811da0e3b1bc0f3edbe3ffb157610a19555d2472ce77070fac0b1dc2cf6968d2ce22708f0dee552260dd1b3c71f4
|
7
|
+
data.tar.gz: ffe06c3e008ce280d33c7ee2b656d49a1a7db2fb05a8e7aedd774504ff4ccfdedd56a7c50518298740b29156ca5dcd462583498df0e38d957d93057312bb61e1
|
data/README.md
CHANGED
@@ -11,14 +11,14 @@ Undercarriage is a set of concerns to add to your application to trim some of th
|
|
11
11
|
## Requirements
|
12
12
|
|
13
13
|
* Ruby >= 2.5
|
14
|
-
* Rails >= 6.0
|
14
|
+
* Rails >= 6.0
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
18
18
|
Add to your application's Gemfile
|
19
19
|
|
20
20
|
```
|
21
|
-
gem 'undercarriage', '~> 0.
|
21
|
+
gem 'undercarriage', '~> 0.5'
|
22
22
|
```
|
23
23
|
|
24
24
|
Run the bundle command
|
@@ -40,10 +40,26 @@ TODO
|
|
40
40
|
Run tests with one of the following
|
41
41
|
|
42
42
|
```
|
43
|
-
$
|
43
|
+
$ bundle exec rspec
|
44
44
|
$ bundle exec rspec spec
|
45
45
|
```
|
46
46
|
|
47
|
+
### Appraisal
|
48
|
+
|
49
|
+
Undercarriage uses [Appraisal](https://github.com/thoughtbot/appraisal) to ensure various dependency versions work as expected
|
50
|
+
|
51
|
+
When dependencies change, run
|
52
|
+
|
53
|
+
```
|
54
|
+
$ bundle exec appraisal install
|
55
|
+
```
|
56
|
+
|
57
|
+
To run tests with Appraisal, run
|
58
|
+
|
59
|
+
```
|
60
|
+
$ bundle exec appraisal rspec
|
61
|
+
```
|
62
|
+
|
47
63
|
## Code Analysis
|
48
64
|
|
49
65
|
Various tools are used to ensure code is linted and formatted correctly.
|
@@ -21,6 +21,7 @@ module Undercarriage
|
|
21
21
|
:collection_action?,
|
22
22
|
:create_action?,
|
23
23
|
:create_actions?,
|
24
|
+
:destroy_action?,
|
24
25
|
:edit_action?,
|
25
26
|
:edit_actions?,
|
26
27
|
:index_action?,
|
@@ -139,6 +140,21 @@ module Undercarriage
|
|
139
140
|
action?('update')
|
140
141
|
end
|
141
142
|
|
143
|
+
##
|
144
|
+
# Check if destroy
|
145
|
+
#
|
146
|
+
# Check if action is the destroy action type. The check will pass if it is a `destroy` action
|
147
|
+
#
|
148
|
+
# Usage
|
149
|
+
# destroy_action? # true
|
150
|
+
# destroy_action? # false
|
151
|
+
#
|
152
|
+
# @return [Boolean] if action is action type
|
153
|
+
#
|
154
|
+
def destroy_action?
|
155
|
+
action?('destroy')
|
156
|
+
end
|
157
|
+
|
142
158
|
##
|
143
159
|
# Check if collection
|
144
160
|
#
|
@@ -41,14 +41,22 @@ module Undercarriage
|
|
41
41
|
def create
|
42
42
|
nested_resource_pre_build
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
respond_to do |format|
|
45
|
+
if @create_resource.save
|
46
|
+
after_create_action
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
nested_resource_build
|
48
|
+
format.html do
|
49
|
+
flash[flash_status_type] = flash_created_message
|
50
50
|
|
51
|
-
|
51
|
+
redirect_to location_after_create
|
52
|
+
end
|
53
|
+
format.json { render :show, status: :created, location: location_after_create }
|
54
|
+
else
|
55
|
+
nested_resource_build
|
56
|
+
|
57
|
+
format.html { render :new, status: :unprocessable_entity }
|
58
|
+
format.json { render json: @create_resource.errors, status: :unprocessable_entity }
|
59
|
+
end
|
52
60
|
end
|
53
61
|
end
|
54
62
|
|
@@ -41,7 +41,14 @@ module Undercarriage
|
|
41
41
|
def destroy
|
42
42
|
@destroy_resource.destroy
|
43
43
|
|
44
|
-
|
44
|
+
respond_to do |format|
|
45
|
+
format.html do
|
46
|
+
flash[flash_status_type] = flash_destroyed_message
|
47
|
+
|
48
|
+
redirect_to location_after_destroy
|
49
|
+
end
|
50
|
+
format.json { head :no_content }
|
51
|
+
end
|
45
52
|
end
|
46
53
|
|
47
54
|
protected
|
@@ -41,14 +41,22 @@ module Undercarriage
|
|
41
41
|
def update
|
42
42
|
nested_resource_pre_build
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
respond_to do |format|
|
45
|
+
if @update_resource.update(update_resource_params)
|
46
|
+
after_update_action
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
nested_resource_build
|
48
|
+
format.html do
|
49
|
+
flash[flash_status_type] = flash_updated_message
|
50
50
|
|
51
|
-
|
51
|
+
redirect_to location_after_update
|
52
|
+
end
|
53
|
+
format.json { render :show, status: :ok, location: location_after_update }
|
54
|
+
else
|
55
|
+
nested_resource_build
|
56
|
+
|
57
|
+
format.html { render :edit }
|
58
|
+
format.json { render json: @update_resource.errors, status: :unprocessable_entity }
|
59
|
+
end
|
52
60
|
end
|
53
61
|
end
|
54
62
|
|
@@ -74,10 +74,10 @@ module Undercarriage
|
|
74
74
|
private
|
75
75
|
|
76
76
|
def flash_message_builder(action, status, past_tense)
|
77
|
-
defaults = flash_message_defaults(
|
77
|
+
defaults = flash_message_defaults(controller_name_singular_title, action, status, past_tense)
|
78
78
|
message = defaults.shift
|
79
79
|
|
80
|
-
I18n.t(message, resource_name:
|
80
|
+
I18n.t(message, resource_name: controller_name_singular_title,
|
81
81
|
downcase_resource_name: controller_name_singular,
|
82
82
|
default: defaults)
|
83
83
|
end
|
@@ -28,11 +28,12 @@ module Undercarriage
|
|
28
28
|
end
|
29
29
|
|
30
30
|
##
|
31
|
-
#
|
31
|
+
# Titleized controller name
|
32
32
|
#
|
33
|
-
def
|
34
|
-
controller_name_singular.
|
33
|
+
def controller_name_singular_title
|
34
|
+
controller_name_singular.titleize
|
35
35
|
end
|
36
|
+
alias controller_name_singular_human controller_name_singular_title
|
36
37
|
|
37
38
|
##
|
38
39
|
# Model name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: undercarriage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Freerksen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.0
|
26
|
+
version: '6.0'
|
27
27
|
description: Undercarriage is a set of concerns to add to your application to trim
|
28
28
|
some of the fat from controllers and models.
|
29
29
|
email:
|