undercarriage 0.4.1 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b12f7949572ff816f2b669ca0a6d94bfe8bce39ba6a744092b16ceedfda4cdac
4
- data.tar.gz: 651b54c29ed119c043ca0542dccadfc7e6f60ffd471d86cbe1988c7f377d7c90
3
+ metadata.gz: 7e851f84eca998dda6de087ad26e9f7c70965d821920d3414e2bfa0fd1a86fa6
4
+ data.tar.gz: 67afdb30e44dec5df059b2d00583b7bf6be28e33b3a0145671c8652f11fef72d
5
5
  SHA512:
6
- metadata.gz: de197de22b4c1cada28489687edeea986d628a7dc3245932e0b33565e9a4061c74dea37b7f5981e24e4348262d22d8df1df026b204edb008c86665299098b8fc
7
- data.tar.gz: da32a07d87b9eccfc756de524410800fc36fa1b63814bb1ea5defa95bf870f854824c98ccae3fc3f8dbbd0192bb97f56e9a3f7921e5448a9a90746dd06ef7e81
6
+ metadata.gz: 48a498285f452088b02057478f75db0e6290e4f0efed219bfd4550b4168fdd6673fe078966fd09d9f0fede51cb0b73d0909fc830c90cdac33e6c4a58cf96d803
7
+ data.tar.gz: b52b08d3e2c191c12d09149111cc12c131bd4044e35810b2db0be967a3717ef9d2b99c9b03100f1212aa4dfd9b2a080d841cd0b66555b8a1a0dd47c438269d03
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.3
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.4'
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
- $ bin/test
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,16 +41,22 @@ module Undercarriage
41
41
  def create
42
42
  nested_resource_pre_build
43
43
 
44
- if @create_resource.save
45
- after_create_action
44
+ respond_to do |format|
45
+ if @create_resource.save
46
+ after_create_action
46
47
 
47
- flash[flash_status_type] = flash_created_message
48
+ format.html do
49
+ flash[flash_status_type] = flash_created_message
48
50
 
49
- redirect_to location_after_create
50
- else
51
- nested_resource_build
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
52
56
 
53
- render :new, status: :unprocessable_entity
57
+ format.html { render :new, status: :unprocessable_entity }
58
+ format.json { render json: @create_resource.errors, status: :unprocessable_entity }
59
+ end
54
60
  end
55
61
  end
56
62
 
@@ -41,9 +41,14 @@ module Undercarriage
41
41
  def destroy
42
42
  @destroy_resource.destroy
43
43
 
44
- flash[flash_status_type] = flash_destroyed_message
44
+ respond_to do |format|
45
+ format.html do
46
+ flash[flash_status_type] = flash_destroyed_message
45
47
 
46
- redirect_to location_after_destroy
48
+ redirect_to location_after_destroy
49
+ end
50
+ format.json { head :no_content }
51
+ end
47
52
  end
48
53
 
49
54
  protected
@@ -41,16 +41,22 @@ module Undercarriage
41
41
  def update
42
42
  nested_resource_pre_build
43
43
 
44
- if @update_resource.update(update_resource_params)
45
- after_update_action
44
+ respond_to do |format|
45
+ if @update_resource.update(update_resource_params)
46
+ after_update_action
46
47
 
47
- flash[flash_status_type] = flash_updated_message
48
+ format.html do
49
+ flash[flash_status_type] = flash_updated_message
48
50
 
49
- redirect_to location_after_update
50
- else
51
- nested_resource_build
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
52
56
 
53
- render :edit, status: :unprocessable_entity
57
+ format.html { render :edit }
58
+ format.json { render json: @update_resource.errors, status: :unprocessable_entity }
59
+ end
54
60
  end
55
61
  end
56
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(controller_name_singular_human, action, status, past_tense)
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: controller_name_singular_human,
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
@@ -69,7 +69,7 @@ module Undercarriage
69
69
  end
70
70
 
71
71
  def resources_path(options = {})
72
- location_path = [resource_namespace, controller_name].compact
72
+ location_path = [resource_namespace, controller_name].compact.map(&:to_sym)
73
73
 
74
74
  polymorphic_path(location_path, options)
75
75
  end
@@ -28,11 +28,12 @@ module Undercarriage
28
28
  end
29
29
 
30
30
  ##
31
- # Singular human name
31
+ # Titleized controller name
32
32
  #
33
- def controller_name_singular_human
34
- controller_name_singular.humanize
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
@@ -4,5 +4,5 @@ module Undercarriage
4
4
  ##
5
5
  # Undercarriage version
6
6
  #
7
- VERSION = '0.4.1'
7
+ VERSION = '0.5.5'
8
8
  end
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.1
4
+ version: 0.5.5
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-03-12 00:00:00.000000000 Z
11
+ date: 2021-05-07 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.3
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.3
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: