undercarriage 0.4.0 → 0.5.4

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: c6bf546b0f940aa2ca8620b00fe2e0e74b947dd307f48cdc4585e1e83c2dd08b
4
- data.tar.gz: 1a324449aea055e2c28498ce4703ba508ee0fe92e9ff1caaac98b5a79ba43152
3
+ metadata.gz: 31eecbc405432e03696e5e1bbf2de1a51f9c8283b98027d10732272527df8a89
4
+ data.tar.gz: 78fdc57d5373a23c9f265a2fc6229798f51c38d5b08afe851301989a58ef5c20
5
5
  SHA512:
6
- metadata.gz: 3fd88e0dcc5bdd688ec644790f4e63f6939ee756ddc8aae4c97b7e03c8e863426a6079fc4092231d4e2ae5de12158dae667dc68666b3de1d306ae24b1022fa56
7
- data.tar.gz: bdd703e2e6620fd9035c85cc75c35a96b000cc02b9d9e13ea9776971e5016132b89e5c48f4c0a4e732fca57d83aaf6c83a77264d4552f6585dac557b446cbed9
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.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,14 +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
- redirect_to location_after_create, notice: flash_created_message
48
- else
49
- nested_resource_build
48
+ format.html do
49
+ flash[flash_status_type] = flash_created_message
50
50
 
51
- render :new, status: :unprocessable_entity
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
- redirect_to location_after_destroy, notice: flash_destroyed_message
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
- 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
- redirect_to location_after_update, notice: flash_updated_message
48
- else
49
- nested_resource_build
48
+ format.html do
49
+ flash[flash_status_type] = flash_updated_message
50
50
 
51
- render :edit, status: :unprocessable_entity
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(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
@@ -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.0'
7
+ VERSION = '0.5.4'
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.0
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-03-11 00:00:00.000000000 Z
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.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: