hot-glue 0.0.8 → 0.0.9

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: ae1088aa0a809a10fb6332fa7ca062e1af6aa39a1c8541dabdf4d8451c5ba04d
4
- data.tar.gz: a3ff6d5d8a171e1d1d361df692f6255f855720609e692c21573d6311fbeb41e2
3
+ metadata.gz: 831970726374d97ef6b5380d122033384777a520ba5fcaeebc9ee79717b82ef1
4
+ data.tar.gz: f45f7a48e78a6bfd62973a11d5b55b24d7ba7a7979855940429ea00398e3ef1f
5
5
  SHA512:
6
- metadata.gz: f65f042a47123cb7a7f69222ddf6618ca085f8cb38bf372179f3bb3da6e47fb07cb383ecba4e0c22642d775db004c0ab111fc99667f575fde62869f7d4c4efba
7
- data.tar.gz: e6c36f5bb8a516ee2e74250000174eede61f39c38c46fb74ac963cfa958ac2c5ba2bd3323832b1359ef452e532b7e01b24e04ff68bb67b28df781ccf04e958a4
6
+ metadata.gz: 23fa8de6cc6460b36d3a867c502a708c6ea825575f25240d28f11f0c0f5a333fc6fe583fa95668d517555bbef96177407432a8c98ca41a29caeca82fa37e765a
7
+ data.tar.gz: a1c9db09d05ab741a85906e31b9cc5336c73f4108f550edbd14166d00f0623b65b1ea8c97a8b9c95c39de55a72bc006cb657ab3d5cddff17258983eb26183ccc
data/.github/FUNDING.yml CHANGED
@@ -1,2 +1,2 @@
1
1
  github: [jasonfb]
2
- custom: ["https://jfb.teachable.com"]
2
+ custom: ["https://www.instagram.com/jfbcodes/"]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.0.7)
4
+ hot-glue (0.0.8)
5
5
  ffaker (~> 2.16)
6
6
  haml-rails (~> 2.0)
7
7
  kaminari (~> 1.2)
@@ -85,7 +85,7 @@ GEM
85
85
  erubi (1.10.0)
86
86
  erubis (2.7.0)
87
87
  ffaker (2.18.0)
88
- ffi (1.14.2)
88
+ ffi (1.15.0)
89
89
  globalid (0.4.2)
90
90
  activesupport (>= 4.2.0)
91
91
  haml (5.2.1)
data/README.md CHANGED
@@ -313,6 +313,8 @@ If you do not want inline editing of your list items but instead to fall back to
313
313
 
314
314
  # VERSION HISTORY
315
315
 
316
+ #### 2021-03-24 - v0.0.9 - fixes in the automatic field label detection; cleans up junk in spec output
317
+
316
318
  #### 2021-03-21 - v0.0.8 - show only flag; more specific spec coverage in generator spec
317
319
 
318
320
  #### 2021-03-20 - v0.0.7 - adds lots of spec coverage; cleans up generated cruft code on each run; adds no-delete, no-create; a working --big-edit with basic data-turbo false to disable inline editing
@@ -55,7 +55,7 @@ module HotGlue
55
55
  class_option :include, type: :string, default: ""
56
56
  class_option :god, type: :boolean, default: false
57
57
  class_option :gd, type: :boolean, default: false # alias for god
58
- class_option :spacs_only, type: :boolean, default: false
58
+ class_option :specs_only, type: :boolean, default: false
59
59
  class_option :no_specs, type: :boolean, default: false
60
60
  class_option :no_delete, type: :boolean, default: false
61
61
  class_option :no_create, type: :boolean, default: false
@@ -104,6 +104,7 @@ module HotGlue
104
104
 
105
105
  @god = options['god'] || options['gd'] || false
106
106
  @specs_only = options['specs_only'] || false
107
+
107
108
  @no_specs = options['no_specs'] || false
108
109
  @no_delete = options['no_delete'] || false
109
110
 
@@ -208,18 +209,16 @@ module HotGlue
208
209
  end
209
210
 
210
211
  assoc_class = eval(assoc.class_name)
211
- if assoc_class.respond_to?(:name)
212
- # display_column = "name"
213
- elsif assoc_class.respond_to?(:to_label)
214
- # display_column = "to_label"
215
- elsif assoc_class.respond_to?(:full_name)
216
- # display_column = "full_name"
217
- elsif assoc_class.respond_to?(:display_name)
218
- # display_column = "display_name"
219
- elsif assoc_class.respond_to?(:email)
220
- # display_column = "email"
212
+
213
+ name_list = [:name, :to_label, :full_name, :display_name, :email]
214
+
215
+
216
+ if name_list.collect{ |field|
217
+ assoc_class.column_names.include?(field.to_s) || assoc_class.instance_methods.include?(field)
218
+ }.any?
219
+ # do nothing here
221
220
  else
222
- exit_message= "*** Oops: Can't find any column to use as the display label for the #{assoc.name.to_s} association on the #{singular_class} model . TODO: Please implement just one of: 1) name, 2) to_label, 3) full_name, 4) display_name, or 5) email directly on your #{assoc.class_name} model (either as database field or model methods), then RERUN THIS GENERATOR. (If more than one is implemented, the field to use will be chosen based on the rank here, e.g., if name is present it will be used; if not, I will look for a to_label, etc)"
221
+ exit_message= "*** Oops: Missing a label for #{assoc.class_name.upcase}. Can't find any column to use as the display label for the #{assoc.name.to_s} association on the #{singular_class} model . TODO: Please implement just one of: 1) name, 2) to_label, 3) full_name, 4) display_name, or 5) email directly on your #{assoc.class_name.upcase} model (either as database field or model methods), then RERUN THIS GENERATOR. (If more than one is implemented, the field to use will be chosen based on the rank here, e.g., if name is present it will be used; if not, I will look for a to_label, etc)"
223
222
  raise(HotGlue::Error,exit_message)
224
223
  end
225
224
  end
@@ -729,18 +728,20 @@ module HotGlue
729
728
  me = eval(singular_class)
730
729
 
731
730
  @display_class ||=
732
- if me.respond_to?("name")
731
+ if me.column_names.include?("name")
732
+ # note that all class object respond_to?(:name) with the name of their own class
733
+ # this one is unique
733
734
  "name"
734
- elsif me.respond_to?("to_label")
735
+ elsif me.column_names.include?("to_label") || me.instance_methods(false).include?(:to_label)
735
736
  "to_label"
736
- elsif me.respond_to?("full_name")
737
+ elsif me.column_names.include?("full_name") || me.instance_methods(false).include?(:full_name)
737
738
  "full_name"
738
- elsif me.respond_to?("display_name")
739
+ elsif me.column_names.include?("display_name") || me.instance_methods(false).include?(:display_name)
739
740
  "display_name"
740
- elsif me.respond_to?("email")
741
+ elsif me.column_names.include?("email") || me.instance_methods(false).include?(:email)
741
742
  "email"
742
- elsif me.respond_to?("number")
743
- display_column = "number"
743
+ elsif me.column_names.include?("number") || me.instance_methods(false).include?(:number)
744
+ "number"
744
745
 
745
746
  else
746
747
  exit_message = "*** Oops: Can't find any column to use as the display label on #{singular_class} model . TODO: Please implement just one of: 1) name, 2) to_label, 3) full_name, 4) display_name, 5) email, or 6) number directly on your #{singular_class} model (either as database field or model methods), then RERUN THIS GENERATOR. (If more than one is implemented, the field to use will be chosen based on the rank here, e.g., if name is present it will be used; if not, I will look for a to_label, etc)"
@@ -769,7 +770,8 @@ module HotGlue
769
770
 
770
771
 
771
772
  def paginate
772
- "= paginate #{plural}"
773
+ "- if #{plural}.respond_to?(:total_pages)
774
+ = paginate #{plural}"
773
775
  end
774
776
 
775
777
  private # thor does something fancy like sending the class all of its own methods during some strange run sequence
@@ -7,102 +7,46 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
7
7
  <%= objest_nest_factory_setup %>
8
8
 
9
9
  before(:each) do
10
- @request.env["devise.mapping"] = Devise.mappings[:account]
11
10
 
12
- sign_in <%= @auth %>, scope: :<%= @auth %>
13
11
  end
14
12
 
15
13
  describe "index" do
16
- it "should respond" do
17
- get :index, xhr: true, format: 'js', params: {
18
- <%= objest_nest_params_by_id_for_specs %>
19
- }
14
+ it "should show me the list" do
15
+
20
16
  end
21
17
  end
22
18
 
23
19
  describe "new" do
24
20
  it "should show form" do
25
- get :new, xhr: true, format: 'js', params: {
26
- <%= objest_nest_params_by_id_for_specs %>
27
- }
21
+
28
22
  end
29
23
  end
30
24
 
31
25
  describe "create" do
32
26
  it "should create a new <%= singular %>" do
33
- expect {
34
- post :create, xhr: true, format: 'js', params: {
35
- <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
36
- <%= singular %>: {
37
- <%= columns_spec_with_sample_data %>
38
- }}
39
- }.to change { <%= @singular_class %>.all.count }.by(1)
40
- assert_response :ok
41
- end
42
27
 
43
- # it "should not create if there are errors" do
44
- # post :create, xhr: true, format: 'js', params: {id: <%= singular %>.id,
45
- # <%= singular %>: {skin_id: nil}}
46
- #
47
- # expect(controller).to set_flash.now[:alert].to(/Oops, your <%= singular %> could not be saved/)
48
- # end
28
+ end
49
29
  end
50
30
 
51
31
  describe "edit" do
52
32
  it "should return an editable form" do
53
- get :edit, xhr: true, format: 'js', params: {
54
- <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
55
- id: <%= singular %>.id
56
- }
57
- assert_response :ok
33
+
58
34
  end
59
35
  end
60
36
 
61
37
  describe "show" do
62
38
  it "should return a view form" do
63
- get :show, xhr: true, format: 'js', params: {
64
- <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
65
- id: <%= singular %>.id
66
- }
67
- assert_response :ok
39
+
68
40
  end
69
41
  end
70
42
 
71
43
  describe "update" do
72
44
  it "should update" do
73
- put :update, xhr: true, format: 'js',
74
- params: {
75
- <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
76
- id: <%= singular %>.id,
77
- <%= singular %>: {
78
- <%= columns_spec_with_sample_data %>
79
- }}
80
-
81
- assert_response :ok
82
45
  end
83
-
84
- # it "should not update if invalid" do
85
- # put :update, xhr: true, format: 'js',
86
- # params: {
87
- # id: <%= singular %>.id,
88
- # <%= singular %>: {
89
- # <%= columns_spec_with_sample_data %>
90
- # }}
91
- #
92
- # assert_response :ok
93
- #
94
- # expect(controller).to set_flash.now[:alert].to(/Oops, your <%= singular %> could not be saved/)
95
- # end
96
46
  end
97
47
 
98
- describe "#destroy" do
48
+ describe "destroy" do
99
49
  it "should destroy" do
100
- post :destroy, format: 'js', params: {
101
- <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
102
- id: <%= singular %>.id
103
- }
104
- assert_response :ok
105
- expect(<%= @singular_class %>.count).to be(0)
106
50
  end
107
51
  end
108
52
  end
@@ -1,3 +1,3 @@
1
1
  module HotGlue
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot-glue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-21 00:00:00.000000000 Z
11
+ date: 2021-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -149,8 +149,8 @@ licenses:
149
149
  - Nonstandard
150
150
  metadata:
151
151
  source_code_uri: https://github.com/jasonfb/hot-glue
152
- documentation_uri: https://jfb.teachable.com/p/gems-by-jason
153
- homepage_uri: https://blog.jasonfleetwoodboldt.com/hot-glue/
152
+ documentation_uri: https://www.instagram.com/jfbcodes/
153
+ homepage_uri: https://jasonfleetwoodboldt.com/hot-glue/
154
154
  post_install_message: |
155
155
  ---------------------------------------------
156
156
  Welcome to Hot Glue - A Scaffold Building Companion for Hotwire + Turbo-Rails
@@ -159,11 +159,11 @@ post_install_message: |
159
159
 
160
160
  * Build plug-and-play scaffolding mixing HAML with the power of Hotwire and Turbo-Rails
161
161
  * Automatically Reads Your Models (make them before building your scaffolding!)
162
- * Excellent for CRUD, lists with pagination, searching, sorting.
163
- * Great for prototyping very.
164
- * Plays nicely with Devise, Kaminari, Haml-Rails, Rspec.
165
- * Create specs automatically along with the controllers.
166
- * Nest your routes model-by-model for built-in poor man's authentication
162
+ * Excellent for CRUD, lists with pagination (coming soon: searching & sorting)
163
+ * Great for prototyping.
164
+ * Plays nicely with Devise, Kaminari, Haml-Rails, Rspec, FontAwesome
165
+ * Create specs automatically along with the generated controllers.
166
+ * Nest your routes model-by-model for built-in poor man's authentication.
167
167
  * Throw the scaffolding away when your app is ready to graduate to its next phase.
168
168
 
169
169
  see README for complete instructions.